DEV Community

Discussion on: Creating PDF Files Without Slowing Down Your App

Collapse
 
simonhessel profile image
Simon Hessel

Hi,

Thank you!

You can prevent the flashing during PDF rendering by replacing the default browser renderer (e.g., iframe) with a solution like react-pdf, which uses canvas and pdfjs to render the file. It includes an onLoadSuccess prop that calls a function once rendering is complete.

For a smoother experience, you can display the previous PDF version until the new one is fully pre-rendered. You can see an example in the official react-pdf REPL, and here’s a relevant code snippet from the repo.

Best,

Simon