admin管理员组

文章数量:1303529

I'm using PDF.js for rendering my documents on a web app I'm working on.

However I need to enable pinch to zoom on mobile devices for this and it doesn't look like the library itself allows native zooming.

Is there a library that I could use to the code to simulate (at the very least) pinch and zoom on the same scale as the viewers dropdown zoom selection?

I'm using PDF.js for rendering my documents on a web app I'm working on.

However I need to enable pinch to zoom on mobile devices for this and it doesn't look like the library itself allows native zooming.

Is there a library that I could use to the code to simulate (at the very least) pinch and zoom on the same scale as the viewers dropdown zoom selection?

Share Improve this question asked Aug 11, 2014 at 22:14 JordanJordan 3411 gold badge4 silver badges12 bronze badges 3
  • There is some work done towards SVG backend for PDF.js, see github./mozilla/pdf.js/tree/master/examples/svgviewer -- you might be interested in that instead of generic viewer. – async5 Commented Aug 11, 2014 at 23:05
  • 1 Whats the performance like on this. The current viewer that I have just destroys the memory usage (In safari debug mode I had it at 100mb-200mb when scrolling zoomed in). I also managed to get touch events working using the Hammer.js library. However, now when i zoom in past 110% on a mobile device it destroys the text in the pdf (leaves only white pages and blue borders where links used to be) – Jordan Commented Aug 13, 2014 at 2:46
  • What version of pdf.js are you using? Have you taken a look at the 'USE_ONLY_CSS_ZOOM' option? See: github./mozilla/pdf.js/issues/2439 and github./mozilla/pdf.js/pull/4834 – Hakkar Commented Sep 12, 2014 at 16:39
Add a ment  | 

1 Answer 1

Reset to default 4

I had found an answer to this solution. I ended up using hammer.js for the pdf.js

http://hammerjs.github.io/

edit

var mc = new Hammer.Manager(myElement, myOptions);

mc.add( new Hammer.Pan({ direction: Hammer.DIRECTION_ALL, threshold: 0 }) );
mc.add( new Hammer.Tap({ event: 'quadrupletap', taps: 4 }) );

mc.on("pan", handlePan);
mc.on("quadrupletap", handleTaps);

本文标签: javascriptPDFjs viewer pinch to zoomStack Overflow