Implement resetting of created streams for annotations
This commit is contained in:
parent
741ce4f7fc
commit
3ecd984758
@ -26,6 +26,7 @@ import {
|
|||||||
isString,
|
isString,
|
||||||
OPS,
|
OPS,
|
||||||
stringToPDFString,
|
stringToPDFString,
|
||||||
|
unreachable,
|
||||||
Util,
|
Util,
|
||||||
warn,
|
warn,
|
||||||
} from "../shared/util.js";
|
} from "../shared/util.js";
|
||||||
@ -250,6 +251,11 @@ class Annotation {
|
|||||||
this.setBorderStyle(dict);
|
this.setBorderStyle(dict);
|
||||||
this.setAppearance(dict);
|
this.setAppearance(dict);
|
||||||
|
|
||||||
|
this._streams = [];
|
||||||
|
if (this.appearance) {
|
||||||
|
this._streams.push(this.appearance);
|
||||||
|
}
|
||||||
|
|
||||||
// Expose public properties using a data object.
|
// Expose public properties using a data object.
|
||||||
this.data = {
|
this.data = {
|
||||||
annotationFlags: this.flags,
|
annotationFlags: this.flags,
|
||||||
@ -554,7 +560,7 @@ class Annotation {
|
|||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
opList.addOp(OPS.endAnnotation, []);
|
opList.addOp(OPS.endAnnotation, []);
|
||||||
appearance.reset();
|
this.reset();
|
||||||
return opList;
|
return opList;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -563,6 +569,30 @@ class Annotation {
|
|||||||
async save(evaluator, task, annotationStorage) {
|
async save(evaluator, task, annotationStorage) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the annotation.
|
||||||
|
*
|
||||||
|
* This involves resetting the various streams that are either cached on the
|
||||||
|
* annotation instance or created during its construction.
|
||||||
|
*
|
||||||
|
* @public
|
||||||
|
* @memberof Annotation
|
||||||
|
*/
|
||||||
|
reset() {
|
||||||
|
if (
|
||||||
|
(typeof PDFJSDev === "undefined" ||
|
||||||
|
PDFJSDev.test("!PRODUCTION || TESTING")) &&
|
||||||
|
this.appearance &&
|
||||||
|
!this._streams.includes(this.appearance)
|
||||||
|
) {
|
||||||
|
unreachable("The appearance stream should always be reset.");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const stream of this._streams) {
|
||||||
|
stream.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -857,6 +887,10 @@ class MarkupAnnotation extends Annotation {
|
|||||||
|
|
||||||
this.appearance = new StringStream("/GS0 gs /Fm0 Do");
|
this.appearance = new StringStream("/GS0 gs /Fm0 Do");
|
||||||
this.appearance.dict = appearanceDict;
|
this.appearance.dict = appearanceDict;
|
||||||
|
|
||||||
|
// This method is only called if there is no appearance for the annotation,
|
||||||
|
// so `this.appearance` is not pushed yet in the `Annotation` constructor.
|
||||||
|
this._streams.push(this.appearance, appearanceStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -395,3 +395,4 @@
|
|||||||
!tiling-pattern-box.pdf
|
!tiling-pattern-box.pdf
|
||||||
!tiling-pattern-large-steps.pdf
|
!tiling-pattern-large-steps.pdf
|
||||||
!issue11555.pdf
|
!issue11555.pdf
|
||||||
|
!issue12337.pdf
|
||||||
|
BIN
test/pdfs/issue12337.pdf
Normal file
BIN
test/pdfs/issue12337.pdf
Normal file
Binary file not shown.
@ -4702,5 +4702,12 @@
|
|||||||
"md5": "f84ce8b7414f6a18e75a6ce69c902501",
|
"md5": "f84ce8b7414f6a18e75a6ce69c902501",
|
||||||
"rounds": 1,
|
"rounds": 1,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
|
},
|
||||||
|
{ "id": "issue12337",
|
||||||
|
"file": "pdfs/issue12337.pdf",
|
||||||
|
"md5": "9165772d5b860bcbcc2478f32e311eb0",
|
||||||
|
"rounds": 2,
|
||||||
|
"lastPage": 1,
|
||||||
|
"type": "fbf"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user