Skip to content

Commit 9205c4f

Browse files
committed
Handle incomplete destinations in PDF documents where the viewport starts at non-zero coordinates (bug 1913617)
Hopefully this makes sense, since it doesn't appear to break "proper" PDF documents in my quick testing.
1 parent 908f453 commit 9205c4f

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

web/pdf_viewer.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,15 +1491,14 @@ class PDFViewer {
14911491
height = 0,
14921492
widthScale,
14931493
heightScale;
1494-
const changeOrientation = pageView.rotation % 180 !== 0;
1495-
const pageWidth =
1496-
(changeOrientation ? pageView.height : pageView.width) /
1497-
pageView.scale /
1498-
PixelsPerInch.PDF_TO_CSS_UNITS;
1499-
const pageHeight =
1500-
(changeOrientation ? pageView.width : pageView.height) /
1501-
pageView.scale /
1502-
PixelsPerInch.PDF_TO_CSS_UNITS;
1494+
// Utilize the viewport "end-points" rather than the effective width/height
1495+
// to avoid problems in PDF documents where the viewport starts at non-zero
1496+
// coordinates (fixes bug 1913617).
1497+
// NOTE: In the majority of PDF documents, those values agree anyway.
1498+
const { viewBox } = pageView.viewport;
1499+
const changeOrientation = pageView.rotation % 180 !== 0,
1500+
pageWidth = changeOrientation ? viewBox[3] : viewBox[2],
1501+
pageHeight = changeOrientation ? viewBox[2] : viewBox[3];
15031502
let scale = 0;
15041503
switch (destArray[1].name) {
15051504
case "XYZ":

0 commit comments

Comments
 (0)