Can I set a limit on initial page rendering?

Which product are you using?
PDF.js Express Plus

PDF.js Express Version
8.7.4

Detailed description of issue
Can I set a limit on initial page rendering? This is to speed up the initial rendering.

Hi there,

Thanks for contacting pdf.js express forums,

I believe you are looking for the setPreRenderLevel API:
https://pdfjs.express/api/Core.html#.SetPreRenderLevel__anchor

Best regards,
Kevin Kim

@kkim thanks.
I have a few questions.

  1. What do the numbers in the setPreRenderLevel API parameters mean? Is it the number of pages?
  2. Does setting the parameter to 0 speed up the initial display?
  3. What is the disadvantage of setting the parameter to 0?
  4. What is the disadvantage of setting the parameter to 10?

Hi there,

This is based on our guide:

A few extra pages may be prerendered at lower priority, so pageComplete may be called for pages that are not currently visible. You can set the prerender level with the SetPreRenderLevel function.

Prerender level to 0 will disable pre-rendering
Prerender level to 10 can increase memory usage because more pages are being stored in the cache. This could potentially lead to performance issues on devices with limited resources.

It’s recommended to test different pre-render levels to find the optimal balance between performance and memory usage for your specific use case and target devices.

Best regards,
Kevin Kim

@kkim sorry, I have Questions.

  1. Does this mean it only works for PDFs with multiple pages?
    Or does pre-rendering increase the initial display speed for PDFs with only one page?
  2. For PDFs that have been loaded once, are they permanently cached to speed up the display?
  3. Where is the cache stored?
  4. Why didn’t the initial display speed change when I changed the value in the setPreRenderLevel API?

Hi there,

setPrerenderLevel will only affect rendering pages before and ahead of the current page.

Any additional loading speed is handled by the pdf.js library:

Best regards,
Kevin Kim