Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML2Canvas cutting off parts of image #1266

Closed
Loki180 opened this issue Nov 14, 2017 · 13 comments
Closed

HTML2Canvas cutting off parts of image #1266

Loki180 opened this issue Nov 14, 2017 · 13 comments

Comments

@Loki180
Copy link

Loki180 commented Nov 14, 2017

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

@Loki180 Loki180 changed the title HTML2Canvas cutting off parts of image HTML2Canvas cutting off parts of image with Transform Scale Nov 14, 2017
@Loki180 Loki180 changed the title HTML2Canvas cutting off parts of image with Transform Scale HTML2Canvas cutting off parts of image Nov 14, 2017
@niklasvh
Copy link
Owner

Is this still an issue with v1.0.0? If so, could you please share an example on jsfiddle.

@no-response no-response bot closed this as completed Dec 12, 2017
@no-response
Copy link

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.

@kakkaraashish
Copy link

@Loki180 Hi did you find the solution for that... I was also facing same problem..

@RahulDudharjiya
Copy link

hey i have same issue can anybody find any solution ?

@mark1828
Copy link

mark1828 commented Dec 3, 2019

me too in 2019, can't find the solution

@mlfactory
Copy link

Same here..

@exeleon
Copy link

exeleon commented Mar 26, 2020

Same problem with version 1.0.0-rc.5

@ttoliveira
Copy link

Same problem version 1.0.0-rc.5

2 similar comments
@jatindumka
Copy link

Same problem version 1.0.0-rc.5

@phuquoc164
Copy link

Same problem version 1.0.0-rc.5

@mlfactory
Copy link

In my Chase - this worked : #265

i could not render background images and it seemed to be cover or contain background size, so i've changed line 350 in 0.4.1 version to:

topPos = isNaN(parseInt(bgposition[1], 10)) ? topPos : parseInt(bgposition[1], 10);

and it works!

@mnedelkoski
Copy link

Even this did not help me. I got the left part of my image cut off, randomly without any pattern. Anyone managed to fix the issues? My version is 1.0.0-rc.5.

@kimnewbie
Copy link

same here in 2023 :'(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests