farling42 / fvtt-pdf-pager

PDF Pager for Foundry
MIT License
6 stars 4 forks source link

Get named destinations to ignore zoom in destination. #60

Closed farling42 closed 1 year ago

farling42 commented 1 year ago

There is a pdfjs flag ignoreDestinationZoom which will ignore the zoom level in named destinations.

We should set this flag to true if an explicit zoom has been set in the module settings.

Unfortunately this flag needs to be set BEFORE the PdfLinkService is created, but AFTER the viewer.html has got far enough to create the preferences object.

farling42 commented 1 year ago

In pdfjs, app.js creates a single PDFLinkService object, and passes ignoreDestinationZoom from AppOptions.get("ignoreDestinationZoom")

But the problem is setting the value in AppOptions between AppOptions being created and the PDFLinkService being created.

farling42 commented 1 year ago

We need to call AppOptions.set("ignoreDestinationZoom", true) very early.

farling42 commented 1 year ago

Some notes: see

document.addEventListener("webviewerloaded", function() {
  PDFViewerApplication.initializedPromise.then(function() {
    // The viewer has now been initialized.
  })
});

from https://github.com/mozilla/pdf.js/wiki/Third-party-viewer-usage

farling42 commented 1 year ago

Note that updatePdfView could probably just call linkService.setHash(anchor)

farling42 commented 1 year ago

Note that AppOptions might be available at event.target.contentWindow.PDFViewerApplicationOptions when processing the 'webviewerloaded' event

farling42 commented 1 year ago

Implemented in 0.40.0