question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The latest version of html2canvas make wrong screenshots

See original GitHub issue

When I use the new version of html2canvas( http://html2canvas.hertzen.com/dist/html2canvas.min.js ) i obtain a bad screenshot, but if i use another version i obtain a good screenshot. imagen Like you can see in the example above, the image is posted down that it should be post, and the down part is cropped. (I let bigger to show that the image is cropped and don’t start since the beggining)

the code: html2canvas(document.querySelector('#portaCanvas')).then( canvas => { let pdf = new jsPDF('p', 'mm',[8650,12900]); //10 times more to show that the image is cropped at the end pdf.addImage(canvas.toDataURL('image/png'), 'PNG', 0, 0); //the screenshot have a blank space above pdf.save(filename); })

imagen When I use a version before it work good. (This have not space in blank around because it’s not necessary)

the code: html2canvas(document.querySelector('#portaCanvas'),{ onrendered: canvas => { let pdf = new jsPDF('p', 'mm',[865,1290]); pdf.addImage(canvas.toDataURL('image/png'), 'PNG', 0, 0); pdf.save(filename); } });

I need to use the new version to can scale it but i face to with this issue

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
Tholem98commented, Feb 10, 2020

@VenkatSarvesh The 0.4.1( https://cdnjs.com/libraries/html2canvas ), but in that version the attribute scale isn’t supported. So, the screenshot is blurred and if there is images it look worst.

Try to add scrollY:-window.scrollY to the options in 1.0.0-rc.5 version, that could help you with your problem

0reactions
Tholem98commented, Mar 5, 2020

This look like it solve my problem https://github.com/niklasvh/html2canvas/issues/1979#issuecomment-527775450

add a if(screen.width < 1024) { document.getElementById("viewport").setAttribute("content", "width=1200px"); }

To change the content of the viewport seems to work

Read more comments on GitHub >

github_iconTop Results From Across the Web

elements on html2canvas screenshot appear in a wrong way
Im using html2canvas integrated to fabricjs on a project and what happens is that: The elements apper cluttered in the screenshot when I...
Read more >
Options - html2canvas
Name Default Description logging true Enable logging for debug purposes width Element width The width of the canvas height Element height The height of the canvas...
Read more >
Top 5 html2canvas Code Examples - Snyk
To help you get started, we've selected a few html2canvas examples, based on popular ways it is used in public projects. Secure your...
Read more >
Export React components as images using html2canvas
Learn how to use html2canvas to export React components as images. This can be helpful for exporting multiple images from a page.
Read more >
JavaScript Screenshots - Medium
JavaScript Screenshots. User reconnaissance with HTML2Canvas. One of my current projects — GitShoes — takes on the important task of user feedback.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found