Merge pull request #14439 from Snuffleupagus/issue-14438
Ignore Annotations with empty /Rect-entries in the display-layer (issue 14438)
This commit is contained in:
commit
a72d188599
@ -40,6 +40,13 @@ import { XfaLayer } from "./xfa_layer.js";
|
|||||||
const DEFAULT_TAB_INDEX = 1000;
|
const DEFAULT_TAB_INDEX = 1000;
|
||||||
const GetElementsByNameSet = new WeakSet();
|
const GetElementsByNameSet = new WeakSet();
|
||||||
|
|
||||||
|
function getRectDims(rect) {
|
||||||
|
return {
|
||||||
|
width: rect[2] - rect[0],
|
||||||
|
height: rect[3] - rect[1],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} AnnotationElementParameters
|
* @typedef {Object} AnnotationElementParameters
|
||||||
* @property {Object} data
|
* @property {Object} data
|
||||||
@ -189,8 +196,7 @@ class AnnotationElement {
|
|||||||
page = this.page,
|
page = this.page,
|
||||||
viewport = this.viewport;
|
viewport = this.viewport;
|
||||||
const container = document.createElement("section");
|
const container = document.createElement("section");
|
||||||
let width = data.rect[2] - data.rect[0];
|
let { width, height } = getRectDims(data.rect);
|
||||||
let height = data.rect[3] - data.rect[1];
|
|
||||||
|
|
||||||
container.setAttribute("data-annotation-id", data.id);
|
container.setAttribute("data-annotation-id", data.id);
|
||||||
|
|
||||||
@ -1842,8 +1848,7 @@ class LineAnnotationElement extends AnnotationElement {
|
|||||||
// that acts as the trigger for the popup. Only the line itself should
|
// that acts as the trigger for the popup. Only the line itself should
|
||||||
// trigger the popup, not the entire container.
|
// trigger the popup, not the entire container.
|
||||||
const data = this.data;
|
const data = this.data;
|
||||||
const width = data.rect[2] - data.rect[0];
|
const { width, height } = getRectDims(data.rect);
|
||||||
const height = data.rect[3] - data.rect[1];
|
|
||||||
const svg = this.svgFactory.create(width, height);
|
const svg = this.svgFactory.create(width, height);
|
||||||
|
|
||||||
// PDF coordinates are calculated from a bottom left origin, so transform
|
// PDF coordinates are calculated from a bottom left origin, so transform
|
||||||
@ -1888,8 +1893,7 @@ class SquareAnnotationElement extends AnnotationElement {
|
|||||||
// trigger for the popup. Only the square itself should trigger the
|
// trigger for the popup. Only the square itself should trigger the
|
||||||
// popup, not the entire container.
|
// popup, not the entire container.
|
||||||
const data = this.data;
|
const data = this.data;
|
||||||
const width = data.rect[2] - data.rect[0];
|
const { width, height } = getRectDims(data.rect);
|
||||||
const height = data.rect[3] - data.rect[1];
|
|
||||||
const svg = this.svgFactory.create(width, height);
|
const svg = this.svgFactory.create(width, height);
|
||||||
|
|
||||||
// The browser draws half of the borders inside the square and half of
|
// The browser draws half of the borders inside the square and half of
|
||||||
@ -1936,8 +1940,7 @@ class CircleAnnotationElement extends AnnotationElement {
|
|||||||
// trigger for the popup. Only the circle itself should trigger the
|
// trigger for the popup. Only the circle itself should trigger the
|
||||||
// popup, not the entire container.
|
// popup, not the entire container.
|
||||||
const data = this.data;
|
const data = this.data;
|
||||||
const width = data.rect[2] - data.rect[0];
|
const { width, height } = getRectDims(data.rect);
|
||||||
const height = data.rect[3] - data.rect[1];
|
|
||||||
const svg = this.svgFactory.create(width, height);
|
const svg = this.svgFactory.create(width, height);
|
||||||
|
|
||||||
// The browser draws half of the borders inside the circle and half of
|
// The browser draws half of the borders inside the circle and half of
|
||||||
@ -1987,8 +1990,7 @@ class PolylineAnnotationElement extends AnnotationElement {
|
|||||||
// trigger for the popup. Only the polyline itself should trigger the
|
// trigger for the popup. Only the polyline itself should trigger the
|
||||||
// popup, not the entire container.
|
// popup, not the entire container.
|
||||||
const data = this.data;
|
const data = this.data;
|
||||||
const width = data.rect[2] - data.rect[0];
|
const { width, height } = getRectDims(data.rect);
|
||||||
const height = data.rect[3] - data.rect[1];
|
|
||||||
const svg = this.svgFactory.create(width, height);
|
const svg = this.svgFactory.create(width, height);
|
||||||
|
|
||||||
// Convert the vertices array to a single points string that the SVG
|
// Convert the vertices array to a single points string that the SVG
|
||||||
@ -2076,8 +2078,7 @@ class InkAnnotationElement extends AnnotationElement {
|
|||||||
// Create an invisible polyline with the same points that acts as the
|
// Create an invisible polyline with the same points that acts as the
|
||||||
// trigger for the popup.
|
// trigger for the popup.
|
||||||
const data = this.data;
|
const data = this.data;
|
||||||
const width = data.rect[2] - data.rect[0];
|
const { width, height } = getRectDims(data.rect);
|
||||||
const height = data.rect[3] - data.rect[1];
|
|
||||||
const svg = this.svgFactory.create(width, height);
|
const svg = this.svgFactory.create(width, height);
|
||||||
|
|
||||||
for (const inkList of data.inkLists) {
|
for (const inkList of data.inkLists) {
|
||||||
@ -2337,6 +2338,10 @@ class AnnotationLayer {
|
|||||||
if (!data) {
|
if (!data) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
const { width, height } = getRectDims(data.rect);
|
||||||
|
if (width <= 0 || height <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (data.annotationType === AnnotationType.POPUP) {
|
if (data.annotationType === AnnotationType.POPUP) {
|
||||||
popupAnnotations.push(data);
|
popupAnnotations.push(data);
|
||||||
continue;
|
continue;
|
||||||
|
3
test/pdfs/.gitignore
vendored
3
test/pdfs/.gitignore
vendored
@ -117,6 +117,7 @@
|
|||||||
!issue11878.pdf
|
!issue11878.pdf
|
||||||
!issue13916.pdf
|
!issue13916.pdf
|
||||||
!issue14023.pdf
|
!issue14023.pdf
|
||||||
|
!issue14438.pdf
|
||||||
!bad-PageLabels.pdf
|
!bad-PageLabels.pdf
|
||||||
!decodeACSuccessive.pdf
|
!decodeACSuccessive.pdf
|
||||||
!issue13003.pdf
|
!issue13003.pdf
|
||||||
@ -500,4 +501,4 @@
|
|||||||
!poppler-937-0-fuzzed.pdf
|
!poppler-937-0-fuzzed.pdf
|
||||||
!PDFBOX-3148-2-fuzzed.pdf
|
!PDFBOX-3148-2-fuzzed.pdf
|
||||||
!poppler-90-0-fuzzed.pdf
|
!poppler-90-0-fuzzed.pdf
|
||||||
!issue14415.pdf
|
!issue14415.pdf
|
||||||
|
BIN
test/pdfs/issue14438.pdf
Normal file
BIN
test/pdfs/issue14438.pdf
Normal file
Binary file not shown.
@ -6196,5 +6196,12 @@
|
|||||||
"file": "pdfs/issue14415.pdf",
|
"file": "pdfs/issue14415.pdf",
|
||||||
"md5": "fa306a250a3d37fe0e7a4b3bba51c91e",
|
"md5": "fa306a250a3d37fe0e7a4b3bba51c91e",
|
||||||
"type": "text"
|
"type": "text"
|
||||||
}
|
},
|
||||||
|
{ "id": "issue14438",
|
||||||
|
"file": "pdfs/issue14438.pdf",
|
||||||
|
"md5": "c4f5a21bbd6567fe08583fc9d3149a38",
|
||||||
|
"rounds": 1,
|
||||||
|
"type": "eq",
|
||||||
|
"annotations": true
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user