html2pdf.js
html2pdf.js copied to clipboard
Support `trimPages` mode to create PDF pages of variable length
When generating PDF documents which
- are meant only for viewing from screen and
- at the same time contain a lot of pictures, infographics, etc which cannot be easily broken between pages of fixed height
it is very convenient to have pages of varying height.
The whole approach would work the following way:
- Set an initial page to be big enough to fit as many content as there possible can be on one page (say,
format: [841.89 * 1.4, 3370.39 * 3]) - Continue calling html2pdf worker in a loop, rendering one page at a time.
- Once
.toPdf()is invoked, it trims that huge fixed-height page to an actual content height.