Skip to content

How to show scrollable all contents of div in pdf using html2canvas #650

@Prasadgws

Description

@Prasadgws

var element = document.getElementById('vb-content-MainDiv');
window.scrollTo(0,0)

    var opt = {
        margin:       0.3,
        filename:     'myfile.pdf',
        image:        { type: 'jpeg', quality: 3 },
        html2canvas:  { scale: 3,allowTaint: true, scale: 2, logging: true, dpi: 300, letterRendering: true, scrollY: -window.scrollY, scrollX: -window.scrollX },
       pagebreak: { mode: ['avoid-all', 'css', 'legacy'] },
        jsPDF:        { unit: 'in', format: 'letter', orientation: 'portrait',precision: '1' }
      };
    
    // choose the element and pass it to html2pdf() function and call the save() on it to save as pdf.
    html2pdf().set(opt).from(element).save();

I have tried the above solution can you please help out?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions