Closed zicklag closed 3 years ago
You could certainly turn the DOM/HTML+CSS into an image first, e.g. using https://github.com/niklasvh/html2canvas, and then embed that image into a PDF file, e.g. using https://github.com/MrRio/jsPDF – all on the client side. But that way, you’ll probably lose the ability to search or highlight text.
On the other hand, on the server side, it’s easy to do via headless Chrome, etc.
Does that help?
Those are great options I had considered, and server side rendering is probably my best bet.
I think I'm going with a different strategy for my app anyway now, and I'm pretty sure this is simply a browser limitation not a limitation of your app so I'll close this now. Thanks! :slightly_smiling_face:
Feel free to close this if it's like something that is fundamentally unsupported by browsers, but I was curious if there was a way to skip the printing step and go immediately to producing a PDF, identical in concept to manually "Print to File", but nicer from a user experience. I'm feeling like it's impossible from what I can find, but I wanted to ask just to make sure. :)