1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Support InkAnnotations without appearance streams (issue 13298) (#13301)

For now, we keep things purposely simple by using straight lines (rather than curves); please see https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G11.2096579
This commit is contained in:
Jonas Jenwald 2021-04-27 11:49:03 +02:00 committed by GitHub
parent 72be684c10
commit 6f4394fcd8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 244 additions and 0 deletions

View file

@ -2552,6 +2552,36 @@ class InkAnnotation extends MarkupAnnotation {
});
}
}
if (!this.appearance) {
// The default stroke color is black.
const strokeColor = this.color
? Array.from(this.color).map(c => c / 255)
: [0, 0, 0];
const borderWidth = this.borderStyle.width || 1;
this._setDefaultAppearance({
xref: parameters.xref,
extra: `${borderWidth} w`,
strokeColor,
pointsCallback: (buffer, points) => {
// According to the specification, see "12.5.6.13 Ink Annotations":
// When drawn, the points shall be connected by straight lines or
// curves in an implementation-dependent way.
// In order to simplify things, we utilize straight lines for now.
for (const inkList of this.data.inkLists) {
for (let i = 0, ii = inkList.length; i < ii; i++) {
buffer.push(
`${inkList[i].x} ${inkList[i].y} ${i === 0 ? "m" : "l"}`
);
}
buffer.push("S");
}
return [points[0].x, points[1].x, points[3].y, points[1].y];
},
});
}
}
}