I\'m looking to create a printable pdf version of my website webpages. Something like express.render() only render the page as pdf
Package
I used html-pdf
Easy to use and allows not only to save pdf as file, but also pipe pdf content to a WriteStream (so I could stream it directly to Google Storage to save there my reports).
Using css + images
It takes css into account. The only problem I faced - it ignored my images. The solution I found was to replace url in src attrribute value by base64, e.g.
You can do it with your code or to use one of online converters, e.g. https://www.base64-image.de/
Compile valid html code from html fragment + css
html document (I just appiled .html() method on jQuery selector).css file.Using this two values (stored in variables html and css accordingly) I've compiled a valid html code using Template string
var htmlContent = `
${html}
`
and passed it to create method of html-pdf.