3 ms·
It's not like there is a direct translation from HTML to PDF. They don't really map 1:1. The PDF exported by a browser from an HTML page is an interpretation of
by rmsaksida 11y ago
It's not like there is a direct translation from HTML to PDF. They don't really map 1:1. The PDF exported by a browser from an HTML page is an interpretation of that content. Converting from HTML is not a straightforward, reliable way to produce PDFs. Sometimes the process turns out beautiful, sometimes it turns out kind of shitty. Not to mention there are PDF features which are not supported by an HTML export (for example, forms).
A DSL designed for PDF creation is a much better way to approach this. It gives you way more control over what you're doing. Concerning pdfkit specifically, I think a JSON file is a gruesome way to design a PDF, but IMO it's still better than converting from HTML unless you're doing something very simple.
- SigmundA 11y agoI sort of disagree, HTML as implemented in PhantomJs, wkhtmltopdf and all interactive browsers is incomplete for paged/print output. However HTML with CCS page media is pretty close to being a complete solution, unfortunately the only implementation currently is the commercial PrinceXML. If someone (Apple or Google) would get wise and implement the full paged media spec then PhantomJS/wkhtmltopdf/your browser might be a viable option for full fidelity print output. See: http://www.webkit.org/projects/printing/ http://www.webkit.org/projects/printing/ http://www.princexml.com/ http://www.princexml.com/ Until then our apps will have to suffer with one layout language for viewing (HTML) and have another for print like this lib.