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

saving element that extends beyond the viewport #1260

Closed
dking3876 opened this issue Nov 3, 2017 · 4 comments
Closed

saving element that extends beyond the viewport #1260

dking3876 opened this issue Nov 3, 2017 · 4 comments

Comments

@dking3876
Copy link

Im trying to use this to save a page, that extends beyond the viewport but it keeps getting cut off. Is there a way to save . below is the code im using. when i make the element small enough to fit in the viewport it works just fine but the image that i get is just far to small for what i need it for, and increasing the size only makes blurry. Some of these images in the size i need them are 1300px+ high

`html2canvas(preview, {
background: '#ffffff',
onrendered: (canvas)=>{

            canvas.toBlob((blob)=>{
                FileSaver.saveAs(blob, 'mysave.png');
            })
            
        }
    })`
@ffflabs
Copy link

ffflabs commented Nov 4, 2017

If the element contained in a container, div, modal, etc that has inner scrolling?

@dking3876
Copy link
Author

The direct container i want to capture does not have scrolling but the parent container does. I will try putting the scrolling on the direct container and see if that works

@dking3876
Copy link
Author

No good. i adjusted so the container im capturing has scrolling to show the full dom, and it still gets cut off at the screen visible section.

any other thoughts??

@ffflabs
Copy link

ffflabs commented Nov 7, 2017

You could try cloning the contents of the element and appending them to the body just while the capturing takes place, then remove it. Something like

var clone = document.getElementById('my_element').cloneNode(true);
//... style the clone so it doesn't have scroll...

return html2canvas(clone, {
		useCORS: true,
		allowTaint: false,
		logging: false
	}).then(function (canvas) {
		document.body.removeChild(clone);
		return canvas;
	});

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

No branches or pull requests

3 participants