You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The provided HTML string should be parsed and then be used the same way as if you would provide an HTML element.
Possible Solution
Doing in the client side
Additional Context
While this library works great on the client side, it is currently not usable within my project.
I want to convert an HTML string to an image.
I do have a lot of HTML templates on my server, these templates can be filled with data from a specific record.
So the client side is sending the infos for which record the template should be adjusted and then downloaded.
My current approach is to read the predefined HTML templates as string and then replace certain keys within with required attributes form my record. But now, I basically do not have an option to convert this adjusted HTML to an image with this library.
I also do not want to move the whole template stuff to the client, since it does not make sense for the front end application to ship 20+ HTML templates.
The text was updated successfully, but these errors were encountered:
Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.
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.
@Dhan3777
Not really, at least not directly.
I'm currently tinkering with the jsdom library, which is a great way to get an HTML element.
However, when generating with toJPG, an error is thrown that HTMLCanvas is not defined.
I haven't found a way around the error yet, will update you here as soon as I find out!
Update:
I ended up modifying the HTML on the server and send the HTML string back to my react app.
There I use the DOMParser to convert the said stringt to an HTMLElement which I then pass to the toPng function of this lib.
There seems to be a problem tho, that the HTML can not be converted, since I get back an empty data url.
In case you're interested, I opened #449
Expected Behavior
The provided HTML string should be parsed and then be used the same way as if you would provide an HTML element.
Possible Solution
Doing in the client side
Additional Context
While this library works great on the client side, it is currently not usable within my project.
I want to convert an HTML string to an image.
I do have a lot of HTML templates on my server, these templates can be filled with data from a specific record.
So the client side is sending the infos for which record the template should be adjusted and then downloaded.
My current approach is to read the predefined HTML templates as string and then replace certain keys within with required attributes form my record. But now, I basically do not have an option to convert this adjusted HTML to an image with this library.
I also do not want to move the whole template stuff to the client, since it does not make sense for the front end application to ship 20+ HTML templates.
The text was updated successfully, but these errors were encountered: