hello to the whole community, I’m using html2pdf javascript in laravel to extrapolate graphs in pdf format, how can I set page breaks so that everything is arranged on multiple pages? I’ve tried everything but I can’t get it to work. thanks so much in advance community.
This is code :
<script>
$('#btn-one').click(function() {
let div = document.querySelector(".tutto");
html2pdf().from(div).save('dashboard-pers-layout-1.pdf');
});
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
2
Answers
Assuming you are using html2pdf.js library,
reference: https://ekoopmans.github.io/html2pdf.js/#page-breaks
Define a CSS class that will be used to set the page break. In your HTML or stylesheet, define a class like this:
This CSS class uses the page-break-before property to force a page break before an element with this class.
Apply the .page-break class to the elements within your HTML that you want to have page breaks before them. For example:
By inserting the elements, you are indicating where the page breaks should occur when generating the PDF.