8

Is there any smart tool or anything I can use to take a screenshot of a rendered localhost website on a Linux server without monitors?

I am using Rocky Linux 9 and I have done group-install of "Server with GUI" but I did not manage to be able to use XRDP sessions or even create an image of a rendered HTML website from commandline. The server is a cloud server, there is no option to connect a monitor or anything. ;-)

For more details: I am running a web application on this server, where users can edit things in HTML/PHP. I want to create a rendered version of the current status, that is saved as an image file to share this image in an intranet (which doesn't have direct network access to the web application).

3
  • 1
    Have a look at Selenium
    – vidarlo
    Commented Jul 23 at 19:00
  • You can also setting up a VNC session as an alternative to XRDP.
    – doneal24
    Commented Jul 23 at 19:12
  • any headless browser will do it. Commented Jul 24 at 14:56

3 Answers 3

23

Google Chrome supports this from command line:

$ google-chrome --headless --screenshot --window-size=1024,4096 https://stackexchange.com/
...
788678 bytes written to file screenshot.png

There is also --print-to-pdf for PDF output.

10

You can do that with Selenium WebDriver. Here's a StackOverflow thread with some examples in various languages.

0

I decided to take another way with this.

I am using html2canvas for JavaScript now. There are some fine-tunings to be done, but it works well. Even though, it's a different approach, because it renders the user's view once he clicks a specific button.

Thanks for help!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .