- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to convert html pages to pdf using wkhtml2pdf
This article will guide you to install a tool which can convert your HTML pages or HTML output to PDF format. This feature will also be helpful to write a code for generating Pdf’s, if we need to send them to a group of customers or clients and for sending reports instead of HTML (which you can send them via emails in PDF format) that will be a value addition to your software.
- Open source and cross platform.
- Convert any HTML web pages to PDF files using WebKit engine.
- Options to add headers and footers
- Table of Content (TOC) generation option.
- Provides batch mode conversions.
- Support for PHP or Python via bindings to libwkhtmltox
Need to install some required fonts which are used for wkhtmltopdf
# yum install -y xorg-x11-fonts-75dpi # yum install -y xorg-x11-fonts-Type1
To get the file, please run the following
# wget https://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.10.0_rc2-static-amd64.tar.bz2
To extract the files –
# tar -xvzf wkhtmltopdf-0.10.0_rc2-static-amd64.tar.bz2 -C /opt # cd /opt # mv wkhtmltopdf-amd64 wkhtmltopdf # mv wkhtmltopdf /usr/local/bin
To convert any HTML web page to PDF, run the following example command. It will convert the given web pages to install-eclipse .pdf as as output to /opt directory.
# wkhtmltopdf http://google.com/ /opt/google.pdf Sample Output: Loading pages (1/6) Counting pages (2/6) Resolving links (4/6) Loading headers and footers (5/6) Printing pages (6/6) Done
After this installation, as mentioned earlier, now you really want a homepage and want to save it as a PDF, then you could use Wkhtmltopdf for that. Seriously, you could use it to generate invoices and save or send, create birthday cards and send them or save them or all other sorts of fun things.
Just use your imagination! That we can save any web pages or html page into PDF format for further use.
- How to convert HTML to PDF using Python
- Convert PDF to CSV using Python
- How to convert PDF files to Excel files using Python?
- How to link pages using absolute URL in HTML?
- How to link pages using relative URL in HTML?
- How to add HTML and CSS to PDF?
- How to include CSS in HTML Pages
- How to Parse HTML pages to fetch HTML tables with Python?
- How to convert a PDF to byte array in Java?
- How to Generate a PDF from an HTML Webpage?
- Recommended way to embed PDF in HTML?
- How to save as PDF on Chrome using Selenium
- How to Address Mapping using Pages in Computer Architecture?
- How to open and close a PDF file using Swift?