Why is the produced canvas empty or cuts off half way through? Make sure that canvas element doesn't hit browser limitations for the canvas size or use the window configuration options to set a custom window size based on the canvas element: await html2canvas(element, { windowWidth: element.
You can get the width and height of PDF document like below, var doc = new jsPDF("p", "mm", "a4"); var width = doc. internal. pageSize.
When placing the canvas in the PDF using the jspdf library makes the image cut off.
html2canvas(myContainer, {background: 'red'}).then (canvas) ->
imgData = canvas.toDataURL('image/jpeg', 1.0)
window.open(imgData) # this is just a test that opens the image in a new tab and it displays nicely, the entire image
pdf = new jsPDF("l", "pt", "b1") # tried a variety of formats but no luck
pdf.addImage(imgData, 'JPEG', 0, 0)
pdf.save('file.pdf') # the generated pdf that contains the image gets trimmed
Does anyone have any ideas how to make the canvas fit?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With