Want to add a pagination option
ccfish86 opened this issue · 1 comments
ccfish86 commented
While the generated file may wrong paging when contains charts/ image etc.
such as
So need manual pagination .
<!-- default a4's width is 595.28px -->
<div id="page" style="width: 595.28px;color: black;background: white;">
<div class="page">
<h3>PDF for Test</h3>
<p>Here is some content for testing!!</p>
</div>
<div class="page">
<h3>PDF for Test</h3>
<p>Here is some content for testing, page3!!</p>
</div>
<div class="page">
<h3>PDF for Test</h3>
<p>Here is some content for testing, page3!!</p>
</div>
</div>
<button id="btn">Generate</button>
and in script we can do like this.
let pages = Array.of( #target#.getElementsByClassName('page'))
let pdf = new jsPdf(/*options*/)
let appendPage = function(page, index) {
html2canvas (dom, opts.html2canvas).then(function(canvas) {
if (index !== 0) pdf.addPage()
pdf.aaddImage(Rendered(canvas, opts)); // no save
});
pages.reduce(async function (pre, cur, index) {
await pre
return appendPage (cur, index)
}, appendPage(pages[0], 0)).then(() => {
pdf.save(fileName + '.pdf')
})
johnnywang1994 commented
Hi~, sorry for the late reply, just added the new feature about this in v1.3.0, thank you for your great advice:))