-1

I have below code

window.scrollTo(0, 0);
    const totPage = document.getElementsByClassName('print');
    for (let index = 1; index < totPage.length;) {
        const input = totPage[index] 
        let orn = input.getAttribute('orientation');
        let canvas = await html2canvas(input,{
            windowWidth: input.scrollWidth,
            windowHeight: input.scrollHeight
        });//.then((canvas) => {
        const imgData = canvas.toDataURL('image/png');
        console.log(imgData)
       
        index++

    }

it generates pdf with image cut off. but strangely when I open console on browser and then try it generates images perfectly, and after then even I closed the console the images are generating correctly. its strange but cannot figure out why this is happening

Md. Parvez Alam
  • 4,326
  • 5
  • 48
  • 108
  • It's a bit difficult to fathom what you mean here. Could you put up a working snippet so we can try it for ourselves - there's missing info e.g. what html you are trying to print, is everything definitely loaded before writing to the canvas etc. – A Haworth Jun 28 '21 at 14:42

1 Answers1