Skip to content

Commit

Permalink
Merge pull request #17908 from calixteman/issue17906
Browse files Browse the repository at this point in the history
Don't render annotations with a null dimension
  • Loading branch information
calixteman authored Apr 10, 2024
2 parents a208d6b + 41aaa08 commit 2c7ae50
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/core/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1119,11 +1119,20 @@ class Annotation {
renderForms,
annotationStorage
) {
const data = this.data;
const { hasOwnCanvas, id, rect } = this.data;
let appearance = this.appearance;
const isUsingOwnCanvas = !!(
this.data.hasOwnCanvas && intent & RenderingIntentFlag.DISPLAY
hasOwnCanvas && intent & RenderingIntentFlag.DISPLAY
);
if (isUsingOwnCanvas && (rect[0] === rect[2] || rect[1] === rect[3])) {
// Empty annotation, don't draw anything.
this.data.hasOwnCanvas = false;
return {
opList: new OperatorList(),
separateForm: false,
separateCanvas: false,
};
}
if (!appearance) {
if (!isUsingOwnCanvas) {
return {
Expand All @@ -1143,7 +1152,7 @@ class Annotation {
);
const bbox = appearanceDict.getArray("BBox") || [0, 0, 1, 1];
const matrix = appearanceDict.getArray("Matrix") || [1, 0, 0, 1, 0, 0];
const transform = getTransformMatrix(data.rect, bbox, matrix);
const transform = getTransformMatrix(rect, bbox, matrix);

const opList = new OperatorList();

Expand All @@ -1159,8 +1168,8 @@ class Annotation {
}

opList.addOp(OPS.beginAnnotation, [
data.id,
data.rect,
id,
rect,
transform,
matrix,
isUsingOwnCanvas,
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/issue17906.pdf.link
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://web.archive.org/web/20240408171222/https://www.myconsumers.org/docs/default-source/default-document-library/consumer_fee_schedule3cb1f27b220b46e38278186d8f609a23fc8e3ea533ad421d8caf5ccbd8df1cb5.pdf
10 changes: 10 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9823,5 +9823,15 @@
"md5": "07d95eabf18aee0cf38f09eb7b1390ec",
"rounds": 1,
"type": "eq"
},
{
"id": "issue17906",
"file": "pdfs/issue17906.pdf",
"md5": "f81c617e5113e0c510a4cfe8b012798e",
"rounds": 1,
"link": true,
"firstPage": 1,
"lastPage": 1,
"type": "eq"
}
]

0 comments on commit 2c7ae50

Please sign in to comment.