Reputation: 210
When I execute the Pinch Zoom gesture (wipe 2 fingers apart or to each other on the display), on the PDF.JS viewer.html in an Cordova app on iOS 11.4.1, the document should be permanently zoomed in or out. But if the document is reloaded/ re-rendered (little loading spinner is shown in PDF.JS toolbar) from a zoom size of approx < 120%, the 'gesturechange' event is no longer fired. The fingers must first be removed from the display and the pinch zoom gesture must be executed again with 2 fingers to get the event fired again. I also tried the library Hammer.JS, but unfortunately here is exactly the same behavior. If the document is further enlarged at a zoom of approx. > 120%, no re-rendering takes place (no loading spinner is shown in PDF.JS toolbar) and the 'gesturechange' event is further fired and everything works. Now the question would be whether you can deactivate re-rendering if necessary and only execute it again at the end of the pinch zoom?
This is the JavaScript example code. PDFJS viewer.html is rendered in an iframe and ExtJS is used.
var viewer = Ext.dom.Query.select('iframe')[0].contentWindow.document.getElementById("viewer");
var pdfViewer = me.el.dom.contentWindow.PDFViewerApplication.pdfViewer;
viewer.addEventListener('gesturechange', function(e) {
if (e.scale < 1.0) {
console.log("PinchOut")
pdfViewer.currentScale = pdfViewer.currentScale - 0.01;
} else if (e.scale > 1.0) {
console.log("PinchIn");
pdfViewer.currentScale = pdfViewer.currentScale + 0.01;
}
})
Upvotes: 0
Views: 1704
Reputation: 26
Try to set the PDFJS.disableTextLayer in viewer.js to "false"
PDFJS.disableTextLayer: false,
then it should work
Upvotes: 1