Open jtauber opened 8 months ago
My workaround is to just add the line:
Html2Image._prepare_html_string = lambda html, _: html
in my code.
At the time, I did not consider that html_str would be used with something other than a very basic HTML string; it was more of a convenient way to transform a string into a valid HTML file than anything. But I indeed see cases where you could already have a full HTML file stored as a string and wouldn't want to transform it in any way.
Currently, there is no "right" way to disable this behavior; your workaround is probably the shortest/cleanest way to disable _prepare_html_string
.
Another way could be to write your HTML strings to files directly and call the screenshot
method using the html_file
parameter, as the HTML files are not pre-processed in any way.
In any case, a simple boolean parameter allowing to disable this behavior would be nice; it will be added when I'll have access to my machine.
Thank you! Hopefully it's helpful to others too!
I noticed after a while using this library (when I set
keep_temp_files=True
) that myhtml_str
is being wrapped as if it were just the body. I can see this is being done_prepare_html_string
where the parameter is calledhtml_body
(which makes it clearer that it's just the body).Is there any way to stop this wrapping and just pass in the full HTML?
Perhaps with a different argument?