Skip to content
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

screenshots all black when using html file or string #117

Open
stormyweathers opened this issue Jun 1, 2023 · 6 comments
Open

screenshots all black when using html file or string #117

stormyweathers opened this issue Jun 1, 2023 · 6 comments

Comments

@stormyweathers
Copy link

stormyweathers commented Jun 1, 2023

Hey there,

Im using V2.0.3 with python 3.8.3

I can't get the basic functionality to work on my machine.
It works if I fetch an html page from the web, but not from local sources.

This example works fine

from html2image import Html2Image
hti = Html2Image()
hti.screenshot(url='https://www.python.org', save_as='python_org.png')

but if I download the webpage locally, and try it again

hti.screenshot(html_file='test.html')

it fails.

I've tried with simpler examples, and html strings as well. All local sources give just a blank black image.

@datawookie
Copy link

I have the same problem.

@vgalin
Copy link
Owner

vgalin commented Jun 16, 2023

I am not currently able to reproduce this issue, could you provide the following ?

  • The HTML file that you're trying to convert into an image (or at list a minimal version of this file that can be used to reproduce the issue)
  • The Chrome Version you're using and your operating system (basically, the content of chrome://version/)

@ghost
Copy link

ghost commented Jul 3, 2023

I just experienced this myself. I can provide the html and chrome version.

chrome version: 114.0.5735.199 (Official Build) (64-bit) (cohort: Stable Installs & Version Pins)
html:

<head><meta` http-equiv="refresh" content="1"></head><center><h2>今日の予約</h2><table border="1" class="dataframe">
  <thead>
    <tr style="text-align: center;">
      <th></th>
      <th>小</th>
      <th>大</th>
      <th>答なし</th>
      <th>✖</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>1</th>
      <td></td>
      <td></td>
      <td>山田太郎</td>
      <td></td>
    </tr>
    <tr>
      <th>2</th>
      <td></td>
      <td></td>
      <td>浅川良太</td>
      <td></td>
    </tr>
    <tr>
      <th>3</th>
      <td></td>
      <td></td>
      <td>鈴木亜美</td>
      <td></td>
    </tr>
    <tr>
      <th>4</th>
      <td></td>
      <td></td>
      <td>鹿見葛城</td>
      <td></td>
    </tr>
  </tbody>
</table></center>

*These names are all made up for testing purposes. No personal/private data here.

Expected output should be something like this:
image

Actual output looks like this:

sortedlist

@jjpaulo2
Copy link

jjpaulo2 commented Jul 5, 2023

Hi @fkkjohn.

I got the same error, and after I read this comment from @vgalin, I could notice that this could be just a permission problem.

Actually I am using the lib as above, and it is working fine to me.

htm = Html2Image(
    custom_flags=[
        '--no-sandbox'
        '--remote-allow-origins=*',
        '--hide-scrollbars'
    ],
    temp_path=f'{getcwd()}/.tmp'
)

@ghost
Copy link

ghost commented Jul 7, 2023

Thank you, Paulo. I read the link you sent, but I'm not running Ubuntu on this computer. It's Windows 10. It could still be a permission problem as you suggest, so I'll have a look. However, I've since moved on to a different solution, so it's not a priority for me at the moment.

Either way, thank you very much for the reply.

@tmblog
Copy link

tmblog commented Sep 2, 2023

I am getting the same, have tried putting in a background color via css but still the same.
Windows and Chrome Version 116.0.5845.141 (Official Build) (64-bit)

UPDATE:
The default bg color is 000000
worked after changing the default:

hti = Html2Image(
    custom_flags=['--default-background-color=FFFFFF', '--hide-scrollbars']
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants