Pdf.js: Render all pages and allow scrolling?

Created on 21 Oct 2015  ·  4Comments  ·  Source: mozilla/pdf.js

In the APIs provided, it seems that we can only render the PDFs page by page.

Does that mean if I want to make a view that allows the user to scroll through the whole pdf, I will have to render the pages one by one in a and insert them to a div?

I guess I will have to deal with the paging stuff myself too?

Most helpful comment

I have just started studying Pdf.js and I am a beginner. Does not the default pre-built viewer use canvas instead and allow also to scroll the whole document pages? I just looked inside the file viewer.js and there you can find canvas element and no svg.
Is there an updated way to get a multiple pages document shown with scroll bar? Thank you, Federico

All 4 comments

Yes, that is true. The reason is that rendering pages that are out of view is expensive in terms of memory. However, you could do something like the svgviewer does to load all pages: https://github.com/mozilla/pdf.js/blob/master/examples/svgviewer/viewer.js. Closing as answered.

@timvandermeij Just curious, I just tested out this svg method, it seems lightning fast comparing to the canvas method. Is there a reason we should use canvas over svg?

The canvas back-end is the back-end that has been supported since the beginning of PDF.js. The SVG back-end is still experimental and cannot do everything that the canvas back-end can do, yet, nor is it as fast and memory efficient. If someone is interested in the SVG back-end to improve its rendering and performance, feel free to open a new PR or contact us on IRC.

I have just started studying Pdf.js and I am a beginner. Does not the default pre-built viewer use canvas instead and allow also to scroll the whole document pages? I just looked inside the file viewer.js and there you can find canvas element and no svg.
Is there an updated way to get a multiple pages document shown with scroll bar? Thank you, Federico

Was this page helpful?
0 / 5 - 0 ratings

Related issues

timvandermeij picture timvandermeij  ·  4Comments

AlexP3 picture AlexP3  ·  3Comments

smit-modi picture smit-modi  ·  3Comments

anggikolo11 picture anggikolo11  ·  3Comments

zerr0s picture zerr0s  ·  3Comments