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

Support LineAnnotations with empty /Rect-entries (issue 6564)

This extends PR 13033 slightly, with a heuristic to support corrupt PDF documents where the `LineAnnotation`s have an empty /Rect-entry. Please note that while I have no idea if this is "correct", this patch at least makes us output the same /BBox as re-saving in Adobe Reader does.
This commit is contained in:
Jonas Jenwald 2021-03-15 16:16:49 +01:00
parent eb92ed12f2
commit 5099f1977f
4 changed files with 112 additions and 0 deletions

View file

@ -23,6 +23,7 @@ import {
assert,
escapeString,
getModificationDate,
isArrayEqual,
isAscii,
isString,
OPS,
@ -2291,6 +2292,17 @@ class LineAnnotation extends MarkupAnnotation {
const borderWidth = this.borderStyle.width;
// If the /Rect-entry is empty, create a fallback rectangle such that we
// get similar rendering/highlighting behaviour as in Adobe Reader.
if (isArrayEqual(this.rectangle, [0, 0, 0, 0])) {
this.rectangle = [
this.data.lineCoordinates[0] - 2 * borderWidth,
this.data.lineCoordinates[1] - 2 * borderWidth,
this.data.lineCoordinates[2] + 2 * borderWidth,
this.data.lineCoordinates[3] + 2 * borderWidth,
];
}
this._setDefaultAppearance({
xref: parameters.xref,
extra: `${borderWidth} w`,