Reset all the canvas states after rendering each annotations (#14105)
- each annotation must be rendered independently of the others. So after having rendered each annotation, the canvas states are reset in order to have something clean to render the next one.
This commit is contained in:
parent
135b9fbcfb
commit
96d0d22d66
@ -1453,7 +1453,7 @@ class CanvasGraphics {
|
||||
}
|
||||
}
|
||||
|
||||
endDrawing() {
|
||||
#restoreInitialState() {
|
||||
// Finishing all opened operations such as SMask group painting.
|
||||
while (this.stateStack.length || this.inSMaskMode) {
|
||||
this.restore();
|
||||
@ -1469,6 +1469,10 @@ class CanvasGraphics {
|
||||
this.ctx.restore();
|
||||
this.transparentCanvas = null;
|
||||
}
|
||||
}
|
||||
|
||||
endDrawing() {
|
||||
this.#restoreInitialState();
|
||||
|
||||
this.cachedCanvases.clear();
|
||||
this.cachedPatterns.clear();
|
||||
@ -2972,19 +2976,24 @@ class CanvasGraphics {
|
||||
}
|
||||
}
|
||||
|
||||
beginAnnotations() {
|
||||
beginAnnotations() {}
|
||||
|
||||
endAnnotations() {}
|
||||
|
||||
beginAnnotation(id, rect, transform, matrix, hasOwnCanvas) {
|
||||
// The annotations are drawn just after the page content.
|
||||
// The page content drawing can potentially have set a transform,
|
||||
// a clipping path, whatever...
|
||||
// So in order to have something clean, we restore the initial state.
|
||||
this.#restoreInitialState();
|
||||
resetCtxToDefault(this.ctx, this.foregroundColor);
|
||||
|
||||
this.ctx.save();
|
||||
this.save();
|
||||
|
||||
if (this.baseTransform) {
|
||||
this.ctx.setTransform.apply(this.ctx, this.baseTransform);
|
||||
}
|
||||
}
|
||||
|
||||
endAnnotations() {
|
||||
this.restore();
|
||||
}
|
||||
|
||||
beginAnnotation(id, rect, transform, matrix, hasOwnCanvas) {
|
||||
this.save();
|
||||
|
||||
if (Array.isArray(rect) && rect.length === 4) {
|
||||
const width = rect[2] - rect[0];
|
||||
@ -3022,8 +3031,8 @@ class CanvasGraphics {
|
||||
this.annotationCanvasMap.set(id, canvas);
|
||||
this.annotationCanvas.savedCtx = this.ctx;
|
||||
this.ctx = context;
|
||||
this.ctx.setTransform(scaleX, 0, 0, -scaleY, 0, height * scaleY);
|
||||
addContextCurrentTransform(this.ctx);
|
||||
this.ctx.setTransform(scaleX, 0, 0, -scaleY, 0, height * scaleY);
|
||||
|
||||
resetCtxToDefault(this.ctx, this.foregroundColor);
|
||||
} else {
|
||||
@ -3050,7 +3059,6 @@ class CanvasGraphics {
|
||||
delete this.annotationCanvas.savedCtx;
|
||||
delete this.annotationCanvas;
|
||||
}
|
||||
this.restore();
|
||||
}
|
||||
|
||||
paintImageMaskXObject(img) {
|
||||
|
2
test/pdfs/issue14105.pdf.link
Normal file
2
test/pdfs/issue14105.pdf.link
Normal file
@ -0,0 +1,2 @@
|
||||
https://github.com/mozilla/pdf.js/files/7291567/Stamp_Problem.pdf
|
||||
|
@ -6545,5 +6545,13 @@
|
||||
"link": true,
|
||||
"type": "eq",
|
||||
"annotations": true
|
||||
},
|
||||
{ "id": "issue14105",
|
||||
"file": "pdfs/issue14105.pdf",
|
||||
"md5": "554174cd461180cbe46c137e846dd527",
|
||||
"rounds": 1,
|
||||
"link": true,
|
||||
"type": "eq",
|
||||
"annotations": true
|
||||
}
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user