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.
This commit is contained in:
Jonas Jenwald 2024-08-22 14:38:56 +02:00
parent 908f453384
commit 687c91d4e2

View File

@ -1491,15 +1491,14 @@ class PDFViewer {
height = 0, height = 0,
widthScale, widthScale,
heightScale; heightScale;
const changeOrientation = pageView.rotation % 180 !== 0; // Utilize the viewport "end-points" rather than the effective width/height
const pageWidth = // to avoid problems in PDF documents where the viewport starts at non-zero
(changeOrientation ? pageView.height : pageView.width) / // coordinates (fixes bug 1913617).
pageView.scale / // NOTE: In the majority of PDF documents those values agree anyway.
PixelsPerInch.PDF_TO_CSS_UNITS; const { viewBox } = pageView.viewport;
const pageHeight = const changeOrientation = pageView.rotation % 180 !== 0,
(changeOrientation ? pageView.width : pageView.height) / pageWidth = changeOrientation ? viewBox[3] : viewBox[2],
pageView.scale / pageHeight = changeOrientation ? viewBox[2] : viewBox[3];
PixelsPerInch.PDF_TO_CSS_UNITS;
let scale = 0; let scale = 0;
switch (destArray[1].name) { switch (destArray[1].name) {
case "XYZ": case "XYZ":