PDF Output

PDF Output

You are here:

[vc_row][vc_column][vc_column_text]

Issue

Exporting your output to PDF is difficult when you can't conform to E2PDF (or you don't want to buy it).  Also, you've likely found plugins such as DKPDF to be sorely lacking in both updates and support.

Use Case

Using a view, I created a table that users need to print.

Solution

Use html2canvas (which, in turn, uses jspdf) to identify which part of your page you want to render as an image which is then saved as a PDF.

Credits to

N/A

Non-Code Changes

You'll need to include the following two JS "libraries", either on a specific page or for your entire site.
https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.min.js

https://cdn.jsdelivr.net/npm/html2canvas@1.0.0-rc.7/dist/html2canvas.min.js

Caveats

Since each CSS attribute has to be handled by jsPDF individually, some are still not supported.

If there are elements inside the "print area" that you don't want to send to the pdf, add the following attribute to its element definition in the html: data-html2canvas-ignore="true".  e.g., I didn't want the repeater Add/Remove icons showing up, so I added some jQuery code to add that attribute to all the elements with the class frm_repeat_buttons - $('.frm_repeat_buttons').attr('data-html2canvas-ignore', 'true');

I never got to the bottom of it, however, in some circumstances, you will get blank pages at the beginning, end or both, so you might have to add code to delete them, e.g., pdf.deletePage(pdf.internal.getNumberOfPages()); will delete the last page of your output.

Code

[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_raw_html]JTNDcHJlJTNFJTBBJTBBJTI0JTI4JTIyJTIzcGRmZXhwb3J0aWNvbiUyMiUyOS5jbGljayUyOGZ1bmN0aW9uJTIwJTI4JTI5JTIwJTdCJTBBJTA5JTBBJTA5dmFyJTIwZWxlbWVudCUyMCUzRCUyMCUyNCUyOCUyNyUyM3NlY3Rpb24tMi0zMDYlMjclMjklM0IlMjAlMkYlMkElMjBzZWN0aW9uLTItMzA2JTIwaXMlMjB3aGF0ZXZlciUyMHRoZSUyMHRvcCUyMG9mJTIwdGhlJTIwZWxlbWVudCUyMHlvdSUyMHdhbnQlMjB0byUyMHByaW50JTIwJTJBJTJGJTBBJTA5aHRtbDJjYW52YXMlMjhlbGVtZW50LmdldCUyODAlMjklMjkudGhl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jglMjduYW1lLnBkZiUyNyUyOSUzQiUwQSUwOSU3RCUyOSUzQiUwQSUwQSU3RCUyOSUzQg==[/vc_raw_html][/vc_column][/vc_row]

Table of Contents
info@fog.org
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram