Ensure that Annotation appearance
-entries are actually Streams
Note how all over the `src/core/annotation.js`-code we're assuming that if an `appearance`-entry exists it's also a Stream. However, we're not actually checking that thoroughly enough which causes issues in some badly generated PDF documents.
This commit is contained in:
parent
e9c8aa63e3
commit
cefaecc2e8
@ -866,7 +866,10 @@ class Annotation {
|
|||||||
if (!(as instanceof Name) || !normalAppearanceState.has(as.name)) {
|
if (!(as instanceof Name) || !normalAppearanceState.has(as.name)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.appearance = normalAppearanceState.get(as.name);
|
const appearance = normalAppearanceState.get(as.name);
|
||||||
|
if (appearance instanceof BaseStream) {
|
||||||
|
this.appearance = appearance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setOptionalContent(dict) {
|
setOptionalContent(dict) {
|
||||||
@ -3013,9 +3016,12 @@ class ButtonWidgetAnnotation extends WidgetAnnotation {
|
|||||||
|
|
||||||
this.data.exportValue = exportValues[1];
|
this.data.exportValue = exportValues[1];
|
||||||
|
|
||||||
|
const checkedAppearance = normalAppearance.get(this.data.exportValue);
|
||||||
this.checkedAppearance =
|
this.checkedAppearance =
|
||||||
normalAppearance.get(this.data.exportValue) || null;
|
checkedAppearance instanceof BaseStream ? checkedAppearance : null;
|
||||||
this.uncheckedAppearance = normalAppearance.get("Off") || null;
|
const uncheckedAppearance = normalAppearance.get("Off");
|
||||||
|
this.uncheckedAppearance =
|
||||||
|
uncheckedAppearance instanceof BaseStream ? uncheckedAppearance : null;
|
||||||
|
|
||||||
if (this.checkedAppearance) {
|
if (this.checkedAppearance) {
|
||||||
this._streams.push(this.checkedAppearance);
|
this._streams.push(this.checkedAppearance);
|
||||||
@ -3058,9 +3064,12 @@ class ButtonWidgetAnnotation extends WidgetAnnotation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const checkedAppearance = normalAppearance.get(this.data.buttonValue);
|
||||||
this.checkedAppearance =
|
this.checkedAppearance =
|
||||||
normalAppearance.get(this.data.buttonValue) || null;
|
checkedAppearance instanceof BaseStream ? checkedAppearance : null;
|
||||||
this.uncheckedAppearance = normalAppearance.get("Off") || null;
|
const uncheckedAppearance = normalAppearance.get("Off");
|
||||||
|
this.uncheckedAppearance =
|
||||||
|
uncheckedAppearance instanceof BaseStream ? uncheckedAppearance : null;
|
||||||
|
|
||||||
if (this.checkedAppearance) {
|
if (this.checkedAppearance) {
|
||||||
this._streams.push(this.checkedAppearance);
|
this._streams.push(this.checkedAppearance);
|
||||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -21,6 +21,7 @@
|
|||||||
!issue14881.pdf
|
!issue14881.pdf
|
||||||
!issue3214.pdf
|
!issue3214.pdf
|
||||||
!issue4665.pdf
|
!issue4665.pdf
|
||||||
|
!checkbox-bad-appearance.pdf
|
||||||
!issue4684.pdf
|
!issue4684.pdf
|
||||||
!issue8092.pdf
|
!issue8092.pdf
|
||||||
!issue5256.pdf
|
!issue5256.pdf
|
||||||
|
BIN
test/pdfs/checkbox-bad-appearance.pdf
Normal file
BIN
test/pdfs/checkbox-bad-appearance.pdf
Normal file
Binary file not shown.
@ -785,6 +785,13 @@
|
|||||||
"rounds": 1,
|
"rounds": 1,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
},
|
},
|
||||||
|
{ "id": "checkbox-bad-appearance",
|
||||||
|
"file": "pdfs/checkbox-bad-appearance.pdf",
|
||||||
|
"md5": "acdac655911cb3d33c3fb1462cf2ad56",
|
||||||
|
"rounds": 1,
|
||||||
|
"type": "eq",
|
||||||
|
"forms": true
|
||||||
|
},
|
||||||
{ "id": "artofwar",
|
{ "id": "artofwar",
|
||||||
"file": "pdfs/artofwar.pdf",
|
"file": "pdfs/artofwar.pdf",
|
||||||
"md5": "7bdd51c327b74f1f7abdd90eedb2f912",
|
"md5": "7bdd51c327b74f1f7abdd90eedb2f912",
|
||||||
|
Loading…
Reference in New Issue
Block a user