This blog is continuation of Convert HTML to PDF in Ruby on Rails Applications – Part-1
Bootstrap css load
We used bootstrap css for our pdf design, it worked perfectly in our development environment, but when we deployed it in server and while testing with some real large data, pdf page crashed unexpectedly. while checking logs we found request time out errors.
Then we googled and found many people raised issue in github saying that they are facing performance issue while using bootstrap (PDF generation very slow with bootstrap css #2642), So we removed bootstrap and wrote our own css for pdf and it worked perfectly.
Solution : Write your own css or just copy the necessary bootstrap css into a file and use. It will save lot of time.
We tried that in our application by giving 5 sec delay and it worked perfectly for the first chart.
Then we decided to save the chart as an image while previewing pdf page and embed that image in the pdf page, while searching for that we came across this solution html2canvas.
I will share the remaining challenges and resolutions in my next blog. Share if you found this useful. Follow @spritlesoftware for more updates.