-
Notifications
You must be signed in to change notification settings - Fork 531
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
SVG with image not working in Safari #214
Comments
Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can. |
Hiya! Thanks for being a part of the Antv community! 💪💯 |
Same problem |
Apparently, the fix is to do a redundant chaining as it takes a little time for IOS to capture the whole data. This worked for me:
Change toJpeg to toSVG or any other format |
@GeekyADAMS i found your workaround does work mostly, but not always. Be good to get a proper solution on this! |
Well, as far as I can tell, this is the best solution for now. The problem is that IOS and MacOS find it hard to “paint” the details of an html content when converting to any image format. You would think that adding enough delay to make sure content is fully rendered would solve the problem but it doesn’t, what works is attempting conversion multiple times in a chain, to make sure it captures all the details. So depending on the level of details in your content, you might need to increase the number of conversion chains and maybe add a lil bit more delay. Maybe a sane thing to do is to create that detect IOS and MacOS devices and then take in a number for how many repeated conversion attempts you want depending on the details of your content to make sure it works every time. As a matter of fact, this can be demoed manually by attempting one conversion and download process after another and see how the level of details captured increases. Maybe the library maintainer can incorporate this in a fix release. |
Hiya! Thanks for being a part of the Antv community! 💪💯 |
This is still an issue |
Can confirm |
I had a similar issue using this library with Electron 12 on Linux (works well on Windows) |
You can use this: save-html-as-image |
Hiya! Thanks for being a part of the Antv community! 💪💯 |
Still there is issue for safari. Not able to download the image properly. Some icons are not visible. Help if anyone has fixed the issue or the solution is working for Safari browser? |
Hiya! Thanks for being a part of the Antv community! 💪💯 |
I was able to solve this issue by using the toBlob function in conjunction with file-saver. const handleDownloadCover = async () => {
if (bannerRef.current === null) {
return;
}
try {
// import { toBlob } from 'html-to-image'
const data = await toBlob(bannerRef.current, {
pixelRatio: 1,
cacheBust: true,
width: 1500,
height: 500,
});
// import filesaver from 'file-saver'
firesaver.saveAs(data, 'my-node.png');
} catch (error) {
console.error(error);
}
}; |
I found this solution, working for me
|
The @kurzenkov-globant solution works perfectly. Thanks |
Hiya! Thanks for being a part of the Antv community! 💪💯 |
Hey again! |
This is still an issue |
I am also encountering this issue. |
@bubkoo can you reopen please |
please reopen |
Still an issue |
still an isue |
I fixed by adding some wait time before downloading the image as mentioned: const url = await toPng(domElement);
const link = document.createElement('a');
await sleep(500)
link.href = url;
link.download = filename;
document.body.appendChild(link);
link.click();
document.body.removeChild(link); Another fix is changing to another library modern-screenshot which is a fork of |
Hi, i am using your incredible library but i have a problem.
I want to convert a SVG with an image inside into a png. In Firefox and Chrome everything works perfect, but in Safari the conversion is ignoring the image inside the SVG.
Here is a codepen (the face is the image) https://codepen.io/RainPara/pen/MWvqZNz
Environment:
IPhone 11 with ios 15
The text was updated successfully, but these errors were encountered: