![]() Better HTML->PDF results (support all HTML tags and CSS).It does not require a server side implementation compare to phantomJS or headless chrome solution.As you mentioned, jspdf/pdfmake gives the user true "download" experience, instead of repurposing "print" as download.If you want to make the PDF file downloadable, you may want to look into phantomJS or headless chrome at the server side. In terms of HTML->PDF, printing from the browser always has a better result than the javascript PDF libraries. This file should look something like so: service: generatePdf provider: name: aws region: us-west-1 runtime: nodejs10.x functions: generatePdf: handler: src/index.generatePdf events: - http: path: /pdf method: get. In pdfmake and jsPDF, If you want to make your PDF to look the same as your HTML, you will need to do HTML->Canvas then paste canvas as a picture inside of PDF. We will need to use a configuration file called serverless.yml (for more details on the file options, see here ). JsPDF does not support external CSS when converting HTML to PDF. Pdfmake does not support HTML->PDF very well: But a lot of times you need to use HTML->Canvas with jsPDF/pdfmake. Actually, printing from the browser does NOT generate PDF as an image (you can test it quickly yourself). It is exactly the opposite of what Marko Tošić said. The only downside I see is the user may be confused about why they're being asked to print something when they weren't expecting a PDF but as the reports aren't generated often it's not a big deal here. ![]() I don't see this approach being suggested anywhere which I find strange. Firefox's print preview shows a preview and the interface is a bit more messy but you can save to PDF in a few clicks.Īm I missing something? Are there any major downsides to my approach? Maybe OS specific issues? Why would you use jspdf or pdfmake over this? Chrome shows a preview and lets you save to PDF in a click. Trigger "window.print()" to print the page in JavaScript. Use CSS to hide everything but the report HTML and use print" styles to style the report. Put directly on the page the HTML needed for my report. It seems like they'll be complicated to work with lots of gotchas. I've been reading about the limitations of jspdf (no UTF8 support) and pdfmake. I want to be able to add graphs, text, UTF-8 support, images, position text but nothing overly crazy in terms of styling and layout apart from that. ![]() I want to create a PDF report within a browser extension tab.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |