DEV Community

Discussion on: Creating PDF Files Without Slowing Down Your App

Collapse
 
sriram_vemparala_e7c93924 profile image
sriram vemparala

Hi @simonhessel ,

Thank you for this great article and I have a few questions about the rendering process.

When I enter some text into the document the PDF blinks and this is due to the rendering process i guess and this gives a bad user experience. is there a way to make the document not to blink ?

Thank you.

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