Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolabaesso authored Jan 4, 2025
2 parents 024ff52 + 49486ef commit d9f838f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
21 changes: 17 additions & 4 deletions base/shared/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ var Annotation = (function AnnotationClosure() {

data.subtype = dict.get('Subtype').name;
data.annotationFlags = dict.get('F');
this.setRectangle(dict.get('Rect'));
this.getAndSetRectangle(dict);
data.rect = this.rectangle;

var color = dict.get('C');
Expand Down Expand Up @@ -117,7 +117,20 @@ var Annotation = (function AnnotationClosure() {
} else {
this.rectangle = [0, 0, 0, 0];
}
},
},

getAndSetRectangle: function Annotation_getAndSetRectangle(dict) {
var rect = dict.get('Rect');
var xref = dict.xref;
if (isArray(rect) && rect.length === 4) {
for (var i = 0; i < 4; i++) {
rect[i] = (typeof rect[i] === "object") ? xref.fetchIfRef(rect[i]) : rect[i];
}
this.setRectangle(rect);
} else {
this.rectangle = [0, 0, 0, 0];
}
},

getData: function Annotation_getData() {
return this.data;
Expand Down Expand Up @@ -330,9 +343,9 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() {
var rawValue = Util.getInheritableProperty(dict, 'V') || '';
var value = (rawValue.name ? rawValue.name : rawValue) || '';
data.fieldValue = stringToPDFString(value);

data.alternativeText = stringToPDFString(dict.get('TU') || '');

data.alternativeID = stringToPDFString(dict.get('TM') || '');

data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"test:jest": "jest --config ./jest.config.json",
"test": "jest --config ./jest.config.json && npm run parse-r && npm run parse-fd",
"test:forms": "cd ./test && sh p2j.forms.sh",
"test:misc": "cd ./test && sh p2j.one.sh misc . \"Expected: 13 success, 6 exceptions with stack trace\" ",
"test:misc": "cd ./test && sh p2j.one.sh misc . \"Expected: 14 success, 5 fail exception with stack trace\" ",
"parse": "./bin/pdf2json.js -f ./test/pdf/fd/form/F1040.pdf -o ./test/target/fd/form",
"parse-s": "./bin/pdf2json.js -f ./test/pdf/fd/form/F1040.pdf -o ./test/target/fd/form -s",
"parse-t": "./bin/pdf2json.js -f ./test/pdf/fd/form/F1040.pdf -o ./test/target/fd/form -s -t",
Expand Down
Binary file added test/pdf/misc/i369_3fields.pdf
Binary file not shown.

0 comments on commit d9f838f

Please sign in to comment.