vgalin / html2image

A package acting as a wrapper around the headless mode of existing web browsers to generate images from URLs and from HTML+CSS strings or files.
MIT License
354 stars 43 forks source link

Screenshot image not getting created in ubuntu server #80

Open gmehta1996 opened 2 years ago

gmehta1996 commented 2 years ago

Hi I am trying to run a script where I'm creating a png image with html but getting the following error: mkdir: cannot create directory ‘/run/user/0’: Permission denied [1021/052947.190152:WARNING:bluez_dbus_manager.cc(247)] Floss manager not present, cannot set Floss enable/disable. [1021/052947.261096:WARNING:sandbox_linux.cc(380)] InitializeSandbox() called with multiple threads in process gpu-process. [1021/052947.504123:ERROR:headless_shell.cc(634)] Writing to file /home/ubuntu/.../screenshot.png was unsuccessful, could not open file: FILE_ERROR_ACCESS_DENIED I'm running this through the root user Following is the code I'm using:

hti = Html2Image( custom_flags=["--no-sandbox","--default-background-color=1"] ) hti.screenshot(html_str=response_html, save_as=image_name) I also tried "--disable-gpu", in the custom flags but still getting the same error What should be the correct solution for this. Thanks