php - Create a multi page PDF from a dynamically created table (div) that is bigger than a single page -
i dynamically creating table using php , mysql containing div , print using jspdf
. until table exceeds single page. first page. have spent weeks, hours of reading, trying , testing , can't print more first page.
here's have:
<!-- jspdf scripts --> <script src="//mrrio.github.io/jspdf/dist/jspdf.debug.js"></script> <script src="//html2canvas.hertzen.com/build/html2canvas.js"></script> $(document).ready(function() { $("#pdfdiv").click(function() { var pdf = new jspdf('p','pt','letter'); pdf.addhtml($('#rentallistcan').first(), function() { pdf.save("rentals.pdf"); }); }); });
i have tried printing page directly formatting doesn't hold.
i have tried css using @page
page-break-inside: auto
doesn't create page breaks. help.
to solve problem, there 2 approaches aware of -
providing options page split
options = { pagesplit: true };
and -
pdf.addhtml($('#somediv'), marginx, marginy, options, function() { pdf.save("doc.pdf"); });
note can split table badly (try , u'll see)- 1 thing can add blank space between rows split before printing page pdf. happens because fromhtml() converts table canvas , splits canvas per page size of pdf.
- using plugin - https://github.com/prashanth-nelli/jspdftableplugin
but customizing table in style not supported here yet. can customize font , colors. if table simple enough, great , easy use plugin.
hope helps!
Comments
Post a Comment