In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to save the web page as a PDF file under Linux, which has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.
Method 1: use a web browser to convert a web page to a PDF file
Although I'm using Mozilla Firefox in this tutorial, you can do the same thing with any of the best browsers available for Linux.
1. Load the web page you want to convert.
2. Find the print option in the browser menu, or use the keyboard shortcut Ctrl + P.
3. By default, it should let you save it as PDF. You need to click "Save", then select the destination and save the page.
Save webpage as PDF in Mozilla Firefox
One of the main problems with this simple approach is that it includes all the elements on the page. This may include comments, footers, etc. You can use a PDF editor to delete some of the content, but this is an extra task.
A better option is to use a browser extension, such as Print Friendly. It allows you to edit and delete parts of the page before downloading PDF.
Method 2: use the terminal to convert the web page to PDF or picture
As you probably already know, you can browse the Internet at the Linux terminal and even download files from the command line. This is not surprising, because you can do more things in the terminal, including downloading the web page as PDF.
A clever open source command line tool, wkhtmltopdf and wkhtmltoimage, can help you convert any HTML web page into PDF or image files.
It uses the Qt WebKit rendering engine to accomplish this task. You can browse its GitHub page for more information.
You should be able to install it from the default repository of your Linux distribution. For Ubuntu-based distributions, you can enter the following command:
Sudo apt install wkhtmltopdf
Whether you want to convert it to a PDF or an image file, its use is very straightforward:
To convert a web page to PDF, enter:
Wkhtmltopdf URL/domain filename.pdf
For example, something like this:
Wkhtmltopdf linuxmint.com mint.pdf
You can choose to use a complete URL like https://linuxmint.com or use a domain name, as shown in the example above.
By default, the generated files are saved in the home directory.
You can also get some fun options when converting web pages.
For example, you can apply grayscale filters to PDF files, make multiple page copies in the same file, and exclude images during conversion.
Grayscale filters may not work for every web page, but you can try it with the command:
Wkhtmltopdf-g google.com googlepage.pdf
To copy multiple pages in the same PDF file, the command is:
Wkhtmltopdf-copies 2 linuxmint.com mint.pdf
And, if you want to exclude images from the page, just type:
Wkhtmltopdf-no-images linuxmint.com mint.pdf
In addition, if you want to convert a web page to an image, the command goes like this:
Wkhtmltoimage linuxmint.com mint.png
Note that unlike the GUI method of using browsers, using these tools through terminals has its limitations. It doesn't seem to be able to successfully convert web pages that use any code snippet.
Like our website, even DuckDuckGo has not been converted to PDF or images. However, simple HTML sites, such as Linuxmint.com, Ubuntu.com, and Google.com, are very effective.
Thank you for reading this article carefully. I hope the article "how to save a web page as a PDF file under Linux" shared by the editor will be helpful to everyone. At the same time, I also hope you can support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.