4 ms·
A great example would be PDF generation for things like invoices. Rather than generating a pdf with something like PHP or Java. Render a regular html page with
by demonshalo 10y ago
A great example would be PDF generation for things like invoices. Rather than generating a pdf with something like PHP or Java. Render a regular html page with all the css you want (super easy compared to drawing a PDF using PHP) and then proceed to use a pdf printer on that page.
You could run such a thing as a microservice using a headless browser or PhantomJS. There are probably better ways to do this but that's one of the first things that popped into my head!
- tjelen 10y agoThe Webkit/PhantomJS PDF export actually supports SVG embedding (as real vectors), Webfonts and many other things. It's possible to create pretty advanced layouts with maps, graphs using that. Even embedding IFrames with e.g. Google Maps works.
- asdfgadsfgasfdg 10y agoThis sounds horrible.. In general all these html->pdf ways of generating pdfs sounds horrible -- why don't people use latex for this?
- demonshalo 10y agoIt is NOT horrible. However, Latex is another way of doing things. Perhaps your requirements should dictate which of the two you should go for!
- SigmundA 10y agoBecause you probably already did the layout work in HTML to display on screen to the user and now just want a PDF version of it. Or you can redo the layout in latex and maintain two layouts. The full print css is actually pretty complete, problem is the only browser that fully supports it is PrinceXML. None of the major browsers seem to care much about print layout.
- asdfgadsfgasfdg 10y agoBut HTML layout is very different to page based layout. HTML is responsive and has no concept of pagination. PDF is paginated and has no concept of responsiveness.
- IneffablePigeon 10y agoCSS2 has the concept of paged layouts: https://www.w3.org/TR/CSS2/page.html https://www.w3.org/TR/CSS2/page.html