I was fully responsible for the frontend development of this Web project. It uses serverside rendering with next.js. Especially the fast preview of PDFs was the focus on the work. PDFs are not meant for the Web so we only show images of the PDF’s pages.
However, pre-rendering images for all PDFs requires additional preprocessing and storage capacity on the server side. We used PDF.js in order to render the images on the device. This is a pratical solution. Nevertheless, the whole PDF has to be downloaded before the rendering starts. This can be a problem for long documents. But the majority of the PDF documents has only a couple of pages (in our case).
The code is available on GitHub.