html2image icon indicating copy to clipboard operation
html2image copied to clipboard

Screenshot of a deferred javascript generated iframe outputs a white image.

Open chrisdewa opened this issue 2 years ago • 0 comments

I'm trying to generate an image of a widget generated by a thirdparty javascript, the full code is as follows:

from html2image import Html2Image

hti = Html2Image(
    custom_flags=['--virtual-time-budget=10000'],
)

html = '''
<script defer src="https://www.livecoinwatch.com/static/lcw-widget.js"></script>
<div class="livecoinwatch-widget-1" lcw-coin="AO" lcw-base="USD" lcw-secondary="ALGO" lcw-period="d" lcw-color-tx="#ffffff" lcw-color-pr="#58c7c5" lcw-color-bg="#1f2434" lcw-border-w="1" ></div>
'''

hti.screenshot(html_str=html, save_as='test.png')

I added the virtual time budget flag to give time for the script to fun and the page to render but the program doesn't seem to slow down and the output image is just blank.

How can i render the image before taking the screenshot?

chrisdewa avatar Jun 07 '22 00:06 chrisdewa