html2pdf.js icon indicating copy to clipboard operation
html2pdf.js copied to clipboard

Overlapping text, odd wrapping, and odd breaking

Open Aphexus opened this issue 3 years ago • 1 comments

https://ncatlab.org/nlab/show/!-modality

Trying to print this page using html2pdf. I can get it to print but the ! is printed about 30px to the right on top of modality. The wrapping is all off as if the margins are not being correctly used for wrapping. Page breaking is done in the middle of lines. Extra blank page.

my code is essentially

var printPage = function(name)
{

    /*
    var opt = {
        margin:       1,
        filename:     name,
        image:        { type: 'jpeg', quality: 0.98 },
        jsPDF:        { unit: 'in', format: 'letter', orientation: 'portrait', floatPrecision:'smart' },
        pagebreak:    { mode: 'avoid-all', after: '#Content' },
        html2canvas:  { allowTaint: true, scale: 1, logging: true, dpi: 300, letterRendering: true, scrollY: -window.scrollY, scrollX: -window.scrollX},
    };*/

    var opt = {
        margin:       1,
        filename:     name,
        html2canvas: { scale: 1, letterRendering: true },
        //image:        { type: 'jpeg', quality: 0.98 },
        //jsPDF:        { unit: 'in', format: 'letter', orientation: 'portrait', floatPrecision:'smart' },
        //pagebreak:    { mode: 'avoid-all', after: '#Content' },
        //html2canvas:  { allowTaint: true, scale: 1, logging: true, dpi: 300, letterRendering: true, scrollY: -window.scrollY, scrollX: -window.scrollX},
    };


    html2pdf().set(opt).from(document.getElementById('Content')).save().then(() => {
                    });
}

printPage(name);

I've been trying various options and things others have done but nothing fixed it. Seems to be a bug in html2pdf and/or html2canvas.

Aphexus avatar Dec 31 '22 00:12 Aphexus

https://github.com/niklasvh/html2canvas/issues/2775#issuecomment-1204988157 Try this

Basnetsuman4 avatar Dec 06 '24 06:12 Basnetsuman4