If we have much data in a div and i am trying to get small complete image of that content, that time it is giving me scroll in image and only visible part of that div is reflecting in image
[jsfiddle]([https://jsfiddle.net/singhalpiyush1993/2m8dcr63/26/])
https://jsfiddle.net/singhalpiyush1993/2m8dcr63/26/
i should get complete content in image
getting only visible part of that saction
+1 i Have this problem, and waiting a correct ansver for this.
Hi Guys,
Is there any idea i can try to resolve this issue?
You fix This Problem with div inside div method,
Up level div overflow scroll and have width and heighth, inside div width and height auto
when you try render, select inside div, then it get real width and heigth of element without scroll capture..
sample.
style.css
width:300px;
heighth:300px;
overflow:scroll;
}
js Code-------------------------------------------------------------------------
var node = document.getElementById('insideDiv');
domtoimage.toPng(node)
.then(function (dataUrl) {
document.getElementById("showImage").src =dataUrl;
})
.catch(function (error) {
console.error('errorr");
});
@piyushSinghalDemo
Finally;
https://jsfiddle.net/2m8dcr63/32/
In the last version of the library, it is no need to add
width: auto; height: auto
Passing the scroll height and width options should be enough:
domtoimage.toPng(node, { width: node.scrollWidth, height: node.scrollHeight })
See a working example here: https://jsfiddle.net/najorcruzcruz/kL9us4x1/6/
what if we have a scrollable-div inside a parent-div and we are converting dom for parent-div then how will we get the visible tags in scrollable-div ?
what if we have a scrollable-div inside a parent-div and we are converting dom for parent-div then how will we get the visible tags in scrollable-div?
You need to get scrollable-div to convert image not the parent div.
In the last version of the library, it is no need to add
width: auto; height: autoPassing the scroll height and width options should be enough:
domtoimage.toPng(node, { width: node.scrollWidth, height: node.scrollHeight })See a working example here: https://jsfiddle.net/najorcruzcruz/kL9us4x1/6/
this solves the problem! GREAT!
Most helpful comment
In the last version of the library, it is no need to add
width: auto; height: autoPassing the scroll height and width options should be enough:
domtoimage.toPng(node, { width: node.scrollWidth, height: node.scrollHeight })See a working example here: https://jsfiddle.net/najorcruzcruz/kL9us4x1/6/