How to Convert Web Page to PDF on Linux

Saving a web page as a PDF is convenient when you archive certain resources or use them for educational purposes.

But how to convert a web page to PDF on Linux?

You can either choose to use the web browser (GUI) on each Linux distribution or use the terminal to turn a web page into a PDF file.

Here I will mention the two methods to help you get the job done.

Method 1: Convert Web Page to PDF Using Web Browser

Although I’m using Mozilla Firefox for this tutorial, you can do the same with any of the best browsers available for Linux.

1. Load the web page you want to convert.

2. Head to the browser menu to find the “To print” or use the keyboard shortcut “CTRL+P.”

3. By default, it should allow you to save it as a PDF. You need to click “Save”, choose the destination and save the webpage.

Save Webpage as PDF in Mozilla Firefox
Save Webpage as PDF in Mozilla Firefox

The only major problem with this simple approach is that it includes all the elements on the page. This can include comments, a footer, etc. You can use a PDF editor to remove parts of it, but that’s an extra task.

A better option is to use a browser extension like printable version. It allows you to edit and delete parts of the web page before downloading the PDF.

Method 2: Convert Webpage to PDF or Images Using Terminal

You probably already know that you can browse the internet in a Linux terminal and even download files using the command line. That’s no surprise considering you can do so much more in the terminal, including downloading a webpage as a PDF.

A nifty open-source command-line tool wkhtmltopdf and wkhtmltoimage comes to the rescue which allows you to convert any HTML webpage into a PDF or image file.

It uses the Qt WebKit rendering engine to accomplish the task. You can explore his GitHub page for more information.

You should be able to install it from your Linux distribution’s default repository. For Ubuntu-based distributions, you can enter the command:

sudo apt install wkhtmltopdf

It’s pretty simple to use, whether you want to convert it to a PDF or image file:

mint htmltopdf

To convert a web page to PDF, type:

wkhtmltopdf URL/domain filename.pdf

As an example, this is what it would look like:

wkhtmltopdf mint.pdf

You can choose to use the full URL like “” or use the domain name as shown in the example above.

The generated file will be saved in the home directory by default.

You also get a few nice options when converting a webpage.

For example, you can apply a grayscale filter to the PDF file, make multiple copies of the page in the same file, and exclude images when converting.

The grayscale filter may not work on all web pages, but you can try using the command:

wkhtmltopdf -g googlepage.pdf

To make multiple copies of pages in the same PDF file, the command would be:

wkhtmltopdf --copies 2 mint.pdf

And, if you want to exclude images from web pages, just type:

wkhtmltopdf --no-images mint.pdf

Also, if you want to convert a web page to an image, the command will look like this:

wkhtmltoimage mint.png

Note that unlike the GUI method using a browser, using these tools through the terminal has its limitations. It doesn’t seem to successfully convert web pages using snippets

Sites like ours and even DuckDuckGo have not been converted to PDF or image. However, simple HTML sites like,,, worked like a charm.


For best results, saving a web page as a PDF using a browser seems to be the way to go. But, if you want more options and go through the terminal, the wkhtmltopdf utility should be useful.

How do you prefer to convert web pages to PDF on Linux? Feel free to share your thoughts in the comments.

Comments are closed.