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.

Image getting cut off/extra white space

See original GitHub issue

Please make sure you are testing with the latest release of html2canvas. Old versions are not supported and issues reported for them will be closed.

Please follow the general troubleshooting steps first:

  • You are using the latest version
  • You are testing using the non-minified version of html2canvas and checked any potential issues reported in the console

Bug reports:

The image is getting cut off at either the bottom or top depending on the scroll position.

html2canvas(document.querySelector(".canvas"), { width: 768, height: 370, windowWidth: document.querySelector(".canvas").scrollWidth, windowHeight: document.querySelector(".canvas").scrollHeight, scrollX: 0, scrollY: -window.scrollY, x: 0, scale: 3 }).then(canvas => { console.log(canvas); var base64image = canvas.toDataURL("image/jpeg"); saveAs(base64image, 'image.jpg'); });

Specifications:

  • html2canvas version tested with: v1.0.0-rc.4
  • Browser & version: Chrome Version 77
  • Operating system: Windows 10

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:9
  • Comments:7

github_iconTop GitHub Comments

11reactions
tradingstratagemcommented, Jan 9, 2020

I fixed this problem by saving the scroll position (x and y), move the page to x=0 y=0, invoke the method and restore the position, it solved the problem

5reactions
orniccommented, Oct 9, 2019

Ye seems to work on 1.00-rc.2 so something changed since then…

Nope, I tested all RCs 1-5 - the only one that not infected with the bug is RC1.

And all workarounds mentioned in https://github.com/niklasvh/html2canvas/issues/1878 wont help, unfortunately.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Remove White Space Under an Image Using CSS
Answer: Use the CSS display property. If you try to put an image inside a <div> element that has borders, you will see...
Read more >
Remove white space below image [duplicate] - Stack Overflow
1) The solution given by @Dave Kok and @Hasan Gursoy: img { vertical-align: top; } /* or bottom */. pros: All display values...
Read more >
How to get rid of the gap under the image ? - GeeksforGeeks
In this article, we will see how to remove the gap generated under the image, while implementing the CSS border property.
Read more >
Is it possible to remove extra white space around product ...
Yes, if all the images are the same dimensions, you can set the image dimensions in the theme settings to match and there...
Read more >
How to Remove White Space or Extra Space Under an Image ...
This video is going to show you How to Remove White Space or Extra Space Under an Image Using CSS.Subscribe to Garnatti one: ......
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