{"id":12734,"date":"2019-03-28T15:15:07","date_gmt":"2019-03-28T15:15:07","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=12734"},"modified":"2019-03-28T15:15:07","modified_gmt":"2019-03-28T15:15:07","slug":"wkhtmltopdf-a-smart-tool-to-convert-website-html-page-to-pdf-in-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/28\/wkhtmltopdf-a-smart-tool-to-convert-website-html-page-to-pdf-in-linux\/","title":{"rendered":"Wkhtmltopdf \u2013 A Smart Tool to Convert Website HTML Page to PDF in Linux"},"content":{"rendered":"<p><strong>Wkhtmltopdf<\/strong>\u00a0is an open source simple and much effective command-line shell utility that enables user to convert any given\u00a0<strong>HTML<\/strong>\u00a0(<strong>Web Page<\/strong>) to\u00a0<strong>PDF<\/strong>\u00a0document or an image (<strong>jpg<\/strong>,\u00a0<strong>png<\/strong>, etc).<\/p>\n<p>Wkhtmltopdf is written in\u00a0<strong>C++<\/strong>\u00a0programming language and distributed under\u00a0<strong>GNU\/GPL<\/strong>\u00a0(<strong>General Public License<\/strong>). It uses\u00a0<strong>WebKit<\/strong>\u00a0rendering layout engine to convert\u00a0<strong>HTML<\/strong>\u00a0pages to<strong>\u00a0PDF<\/strong>\u00a0document without loosing the quality of the pages. Its is really very useful and trustworthy solution for creating and storing snapshots of web pages in real-time.<\/p>\n<h3>Wkhtmltopdf Features<\/h3>\n<ol>\n<li>Open source and cross platform.<\/li>\n<li>Convert any\u00a0<strong>HTML<\/strong>\u00a0web pages to\u00a0<strong>PDF<\/strong>\u00a0files using\u00a0<strong>WebKit<\/strong>\u00a0engine.<\/li>\n<li>Options to add headers and footers<\/li>\n<li>Table of Content (<strong>TOC<\/strong>) generation option.<\/li>\n<li>Provides batch mode conversions.<\/li>\n<li>Support for\u00a0<strong>PHP<\/strong>\u00a0or\u00a0<strong>Python<\/strong>\u00a0via bindings to libwkhtmltox.<\/li>\n<\/ol>\n<p>In this article we will show you how to install\u00a0<strong>Wkhtmltopdf<\/strong>\u00a0program under Linux systems using source tarball files.<\/p>\n<h3>Install Evince (PDF Viewer)<\/h3>\n<p>Let\u2019s install\u00a0<strong>evince<\/strong>\u00a0(a\u00a0<strong>PDF<\/strong>\u00a0reader) program for viewing\u00a0<strong>PDF<\/strong>\u00a0files in Linux systems.<\/p>\n<pre>$ sudo yum install evince             [RHEL\/CentOS and Fedora]\r\n$ sudo dnf install evince             [On Fedora 22+ versions]\r\n$ sudo apt-get install evince         [On Debian\/Ubuntu systems]\r\n<\/pre>\n<h3>Download Wkhtmltopdf Source File<\/h3>\n<p>Download\u00a0<strong>wkhtmltopdf<\/strong>\u00a0source files for your\u00a0<strong>Linux<\/strong>\u00a0architecture using\u00a0<a href=\"https:\/\/www.tecmint.com\/10-wget-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">Wget command<\/a>, or you can also download latest versions (current stable series is\u00a0<strong>0.12.4<\/strong>) at\u00a0<a href=\"http:\/\/wkhtmltopdf.org\/downloads.html\" target=\"_blank\" rel=\"nofollow noopener\">wkhtmltopdf download<\/a>\u00a0page.<\/p>\n<h5>On 64-bit Linux OS<\/h5>\n<pre>$ wget https:\/\/github.com\/wkhtmltopdf\/wkhtmltopdf\/releases\/download\/0.12.4\/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz\r\n<\/pre>\n<h5>On 32-bit Linux OS<\/h5>\n<pre>$ wget https:\/\/github.com\/wkhtmltopdf\/wkhtmltopdf\/releases\/download\/0.12.4\/wkhtmltox-0.12.4_linux-generic-i386.tar.xz<\/pre>\n<h3>Install Wkhtmltopdf in Linux<\/h3>\n<p>Extract the files to a current working directory using following\u00a0<a href=\"https:\/\/www.tecmint.com\/18-tar-command-examples-in-linux\/\" target=\"_blank\" rel=\"noopener\">tar command<\/a>.<\/p>\n<pre><strong>------ On 64-bit Linux OS ------<\/strong>\r\n$ sudo tar -xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz \r\n\r\n<strong>------ On 32-bit Linux OS ------<\/strong>\r\n$ sudo tar -xvzf wkhtmltox-0.12.4_linux-generic-i386.tar.xz \r\n<\/pre>\n<p>Install the\u00a0<strong>wkhtmltopdf<\/strong>\u00a0under\u00a0<strong>\/usr\/bin<\/strong>\u00a0directory for easy execution of program from any path.<\/p>\n<pre>$ sudo cp wkhtmltox\/bin\/wkhtmltopdf \/usr\/bin\/\r\n<\/pre>\n<h3>How to Use Wkhtmltopdf?<\/h3>\n<p>Here we will see how to covert remote\u00a0<strong>HTML<\/strong>\u00a0pages to\u00a0<strong>PDF<\/strong>\u00a0files, verify information, view created files using\u00a0<strong>evince<\/strong>\u00a0program from the\u00a0<strong>GNOME<\/strong>\u00a0Desktop.<\/p>\n<h4>Convert Website HTML Page to PDF File<\/h4>\n<p>To convert any website\u00a0<strong>HTML<\/strong>\u00a0web page to\u00a0<strong>PDF<\/strong>, run the following example command. It will convert the given webpage to\u00a0<a href=\"https:\/\/www.tecmint.com\/sudoers-configurations-for-setting-sudo-in-linux\/\" target=\"_blank\" rel=\"noopener\">10-Sudo-Configurations.pdf<\/a>\u00a0in current working directory.<\/p>\n<pre># wkhtmltopdf https:\/\/www.tecmint.com\/sudoers-configurations-for-setting-sudo-in-linux\/ 10-Sudo-Configurations.pdf\r\n<\/pre>\n<h5>Sample Output :<\/h5>\n<pre>Loading pages (1\/6)\r\nCounting pages (2\/6)\r\nResolving links (4\/6)\r\nLoading headers and footers (5\/6)\r\nPrinting pages (6\/6)\r\nDone<\/pre>\n<h4>View Generated PDF File<\/h4>\n<p>To verify that the file is created, use the following command.<\/p>\n<pre>$ file 10-Sudo-Configurations.pdf\r\n<\/pre>\n<h5>Sample Output :<\/h5>\n<pre><strong>10-Sudo-Configurations.pdf: PDF document, version 1.4<\/strong><\/pre>\n<h4>View Information of Generated PDF File<\/h4>\n<p>To view the information of generated file, issue the following command.<\/p>\n<pre>$ pdfinfo 10-Sudo-Configurations.pdf<\/pre>\n<h5>Sample Output :<\/h5>\n<pre>Title:          10 Useful Sudoers Configurations for Setting 'sudo' in Linux\r\nCreator:        wkhtmltopdf 0.12.4\r\nProducer:       Qt 4.8.7\r\nCreationDate:   Sat Jan 28 13:02:58 2017\r\nTagged:         no\r\nUserProperties: no\r\nSuspects:       no\r\nForm:           none\r\nJavaScript:     no\r\nPages:          13\r\nEncrypted:      no\r\nPage size:      595 x 842 pts (A4)\r\nPage rot:       0\r\nFile size:      697827 bytes\r\nOptimized:      no\r\nPDF version:    1.4\r\n<\/pre>\n<h4>View Created PDF File<\/h4>\n<p>Take a look at the newly created\u00a0<strong>PDF<\/strong>\u00a0file using\u00a0<strong>evince<\/strong>\u00a0program from the desktop.<\/p>\n<pre>$ evince 10-Sudo-Configurations.pdf<\/pre>\n<h5>Sample Screenshot :<\/h5>\n<p>Looks pretty nice under my Linux Mint 17 box.<\/p>\n<div id=\"attachment_24386\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/10\/View-Website-Page-in-PDF.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-24386\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/10\/View-Website-Page-in-PDF.png\" sizes=\"auto, (max-width: 1020px) 100vw, 1020px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/10\/View-Website-Page-in-PDF.png 1020w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/10\/View-Website-Page-in-PDF-768x575.png 768w\" alt=\"View Website Page in PDF\" width=\"1020\" height=\"764\" aria-describedby=\"caption-attachment-24386\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-24386\" class=\"wp-caption-text\">View Website Page in PDF<\/p>\n<\/div>\n<h4>Create TOC (Table Of Content) of a Page to PDF<\/h4>\n<p>To create a table of content for a\u00a0<strong>PDF<\/strong>\u00a0file, use the option as\u00a0<strong>toc<\/strong>.<\/p>\n<pre>$ wkhtmltopdf toc https:\/\/www.tecmint.com\/sudoers-configurations-for-setting-sudo-in-linux\/ 10-Sudo-Configurations.pdf\r\n<\/pre>\n<h5>Sample Output :<\/h5>\n<pre>Loading pages (1\/6)\r\nCounting pages (2\/6)\r\n<strong>Loading TOC (3\/6)<\/strong>\r\nResolving links (4\/6)\r\nLoading headers and footers (5\/6)\r\nPrinting pages (6\/6)\r\nDone<\/pre>\n<p>To check the\u00a0<strong>TOC<\/strong>\u00a0for the created file, again use evince program.<\/p>\n<pre>$ evince 10-Sudo-Configurations.pdf<\/pre>\n<h5>Sample Screenshot :<\/h5>\n<p>Take a look at the picture below. it looks even more better than the above.<\/p>\n<div id=\"attachment_24387\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/10\/Create-Website-Page-Table-of-Contents-in-PDF.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-24387\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/10\/Create-Website-Page-Table-of-Contents-in-PDF.png\" sizes=\"auto, (max-width: 1020px) 100vw, 1020px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/10\/Create-Website-Page-Table-of-Contents-in-PDF.png 1020w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/10\/Create-Website-Page-Table-of-Contents-in-PDF-768x575.png 768w\" alt=\"Create Website Page to Table of Contents in PDF\" width=\"1020\" height=\"764\" aria-describedby=\"caption-attachment-24387\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-24387\" class=\"wp-caption-text\">Create Website Page to Table of Contents in PDF<\/p>\n<\/div>\n<h4>Wkhtmltopdf Options and Usage<\/h4>\n<p>For\u00a0<strong>Wkhtmltopdf<\/strong>\u00a0more usage and options, use the following help command. It will display list of all available options that you can use with it.<\/p>\n<pre>$ wkhtmltopdf --help<\/pre>\n<p><a href=\"https:\/\/www.tecmint.com\/wkhtmltopdf-convert-website-html-page-to-pdf-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wkhtmltopdf\u00a0is an open source simple and much effective command-line shell utility that enables user to convert any given\u00a0HTML\u00a0(Web Page) to\u00a0PDF\u00a0document or an image (jpg,\u00a0png, etc). Wkhtmltopdf is written in\u00a0C++\u00a0programming language and distributed under\u00a0GNU\/GPL\u00a0(General Public License). It uses\u00a0WebKit\u00a0rendering layout engine to convert\u00a0HTML\u00a0pages to\u00a0PDF\u00a0document without loosing the quality of the pages. Its is really very useful and &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/28\/wkhtmltopdf-a-smart-tool-to-convert-website-html-page-to-pdf-in-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Wkhtmltopdf \u2013 A Smart Tool to Convert Website HTML Page to PDF in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12734","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12734","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=12734"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12734\/revisions"}],"predecessor-version":[{"id":12735,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12734\/revisions\/12735"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=12734"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=12734"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=12734"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}