Closed manuelpoelzl closed 4 months ago
+1 @manuelpoelzl
I also have same issue
Is your element a div
? I had a similar issue when the element I was trying render was a span
, but I saw this comment and changed the element to be a div
and that has fixed this issue, although I don't fully understand why (possibly to do with inline vs block?).
In my case it is a div
with 3 other divs
inside of it, so nothing too complicated I'd say.
Can't solve it the way you described @Ninamma. The HTML element I'm trying to convert to an image is rather simple:
<div id="mainNode" style="background-color: red;display: flex">
<h2>TEST</h2>
</div>
All I get is still data:,
Try adding height and width to the container where HTML is wrapped.
Unfortunately I still get the same result, even with width and height specified, I even tried to wrap this div with another div that has width and height specified, without success.
<div id="mainNode" style="background-color: red;display: flex; height:350px; width:900px;">
<h2>TEST</h2>
</div>
Solved:
adding width
and height
as options to the toPng
function worked
I'm unable to get any image from a valid HTMLElement. The HTML looks fine but the
toJPG
andtoPNG
functions return an empty data url .Expected Behavior
The HTML should be converted to an image and the data url should get returned.
Current Behavior
The dataUrl is
data:,
for a perfectly fine HTMLPossible Solution
N/A
Steps To Reproduce
documentElement
toPng
function with the said elementdata:,
Your Environment