One issue we ran into in browser was the huge size overhead from vfs_fonts - is there a preferred workaround to this issue (we had to serve it separately from the rest of the app), or any solution in the pipeline?
Pdfmake – PDF printing in pure JavaScript
11–20 of 49 posts
Re: Pdfmake – PDF printing in pure JavaScript
#12Earlier quoted context omitted.
PDF.js is a Portable Document Format (PDF) viewer . jsPDF prints using: var doc = new jsPDF(); doc.setFontSize(40); doc.text(35, 25, "Paranyan loves jsPDF"); doc.addImage(imgData, 'JPEG', 15, 40, 180, 160); Pdfmake on the other hand: var dd = { content: [ 'First paragraph', 'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines' ] }
jsPDF doesn't trim each line like Pdfmake does. Pdfmake however supports new pages, witch jsPDF doesn't. Would be cool if Pdfmake didn't trim the lines!
Re: Pdfmake – PDF printing in pure JavaScript
#13Right now I'm using PhantomJS to render an HTML page. It supports styling via CSS, multiple pages, etc etc. What advantages does this have?
Re: Pdfmake – PDF printing in pure JavaScript
#14Right now I'm using PhantomJS to render an HTML page. It supports styling via CSS, multiple pages, etc etc. What advantages does this have?
Re: Pdfmake – PDF printing in pure JavaScript
#15There's also https://github.com/devongovett/pdfkit , which I've used to bulk-print ticket envelopes for an event. It does support multiple pages, as I had one PDF file per event occurrence (with 50-80 envelopes per).
Re: Pdfmake – PDF printing in pure JavaScript
#16This looks really well done. Any chance that it could emulate the functionality of wkhtmltopdf in the browser (a.k.a. CSS styling, structure from HTML)?
First you would need a pure js web browser, the closest thing currently being zombie I think. If you didn't care about running on the server then you could take advantage of the browser the lib is running in to get the current computed layout from the active dom and transform into the PDF layout, still a big job but the heavy lift is done by the browser. Telerik does this in their Kendo lib, where they render a active dom element to thier abstracted vector graphics model, then have PDF, SVG and Canvas renders for that: http://docs.telerik.com/kendo-ui/framework/drawing/drawing-d...
Re: Pdfmake – PDF printing in pure JavaScript
#17Right now I'm using PhantomJS to render an HTML page. It supports styling via CSS, multiple pages, etc etc. What advantages does this have?
Side note: Under the hood, PhantomJS uses wkhtmltopdf. You can probably save yourself some overhead using the wkhtmltopdf binary directly.