Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

html2pdf() javascript in laravel page-break for multiple pdf pages

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>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Assuming you are using html2pdf.js library,

<script>
    $('#btn-one').click(function() {
        let div = document.querySelector(".tutto");
        html2pdf().set({
            pagebreak: { mode: 'avoid-all' }
        }).from(div).save('dashboard-pers-layout-1.pdf');
    });
</script>

reference: https://ekoopmans.github.io/html2pdf.js/#page-breaks

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading