I'm working with a pdf viewer, that will load a pdf file from server (nodejs) and then rendering on client side to allow user reading direct in my site.
I'm using pdf.js to rendering pdf file on client side. The problem is client side must download entire pdf file before they can parse and render it, so if the file is too large (~200MB in my case), user must wait for download entire 200MB.
I researched and i think i can solve this problem by 2 ways:
Split the large pdf file into many smaller pdf files on the server side, and serve only specific small file on-demand. But this way, i will lost some important metadata like the pdf outlines,...
Using pdf.js direct in server side, get the pdf pages and then serve each page as binary to client side, client side will also use pdf.js (addPage function) to add each page to their viewer. But i don't know it is possible or not.
So what should i do to solve this problem? Thank you so much.
The best solution is to optimize all your PDF files for web.
The default settings of pdf.js
will load only the portion it needs to render.
See here for more info.