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.

HTML2Canvas cutting off parts of image

See original GitHub issue

Hello!

I’m building a Canvas tool and I’m having an issue with HTML2Canvas where its cutting off part of the image inside of the div when the image is moved to the left or right using jquery’s Drag function.

The issue seems to be with a zoom function that I have, the zoom scales the image using transform. Even though the image is seen inside of the div HTML2Canvas still cuts parts of it out.

The Code that I’ve used for HTML2Canvas is pretty simple, I’ve also tried making sure the page is at the top of the page but it still doesn’t work.

`$(function() { $(“.button-2”).click(function() { $(‘html,body’).scrollTop(0); html2canvas($(“.canvas-cut”), {

        onrendered: function(canvas) {
            theCanvas = canvas;
            canvas.toBlob(function(blob) {
                saveAs(blob, "Dashboard.png");
                alert("Done");
            });
        }
    });
});

});`

The image is within a few divs

<div class="column-2 w-col w-col-10"> <div class="canvas-cut"> <div class="image-container"> <div class="border"></div> <img id="drag" src="uploads/<?php echo $_SESSION['image']; ?>" class="image-2"> </div> </div> </div>

The div is captured well but the image is sometimes cut off.

Here is the issue screenshot from 2017-11-14 12-43-46

Also

screenshot from 2017-11-14 12-50-12

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
RahulDudharjiyacommented, Oct 2, 2018

hey i have same issue can anybody find any solution ?

3reactions
no-response[bot]commented, Dec 12, 2017

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don’t have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Html2Canvas image is getting cut - Stack Overflow
It happens when window is scrolled. To work around this problem you can pass negative of whatever window is scrolled by. html2canvas(htmlSource, ...
Read more >
Image cut from the top · Issue #2386 · niklasvh/html2canvas
I am creating a multi page PDF from html using jspdf and html2canvas but my image is getting cut off little from top...
Read more >
HTML : Html2Canvas image is getting cut - YouTube
HTML : Html2Canvas image is getting cut [ Gift : Animated Search Engine : https://bit.ly/AnimSearch ] HTML : Html2Canvas image is getting ...
Read more >
HTML2Canvas image cut off issue : r/learnjavascript - Reddit
HTML2Canvas cuts of the left part of the image, no matter of the image width or height. The worst thing at the moment...
Read more >
FAQ - html2canvas
Why aren't my images rendered? · Why is the produced canvas empty or cuts off half way through? · Why doesn't CSS property...
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