wkhtmltopdf - a set of two utilities command line for rendering HTML-files or web pages using the WebKit engine:
/usr/local/bin/wkhtmltopdf-amd64
/usr/local/bin/wkhtmltopdf
/usr/local/bin/wkhtmltoimage
Utilities available on hosting default. The examples below use version 0.12 for the wkhtmltopdf utility. To use version 0.10, just replace the utility name with wkhtmltopdf
on wkhtmltopdf-amd64
.
View brief documentation:
wkhtmltopdf -h
wkhtmltoimage -h
View detailed documentation:
wkhtmltopdf -H
wkhtmltoimage -H
Launch format:
wkhtmltopdf <URL or path to the source HTML file> <path and name of the output PDF file>
wkhtmltoimage <URL or path to HTML source file> <path and name of output image file>
A simple example of converting a web page:
wkhtmltopdf http://google.com google.pdf
Или:
/usr/local/bin/wkhtmltopdf http://google.com google.pdf
wkhtmltoimage http://google.com google.png
Или:
/usr/local/bin/wkhtmltoimage http://google.com google.png
Simple conversion example HTML-document:
wkhtmltopdf /home/example/way/to/file/document.html document.pdf
Или:
/usr/local/bin/wkhtmltopdf /home/example/way/to/file/document.html document.pdf
Where example
this hosting account name.
wkhtmltoimage /home/example/way/to/file/document.html document.png
Или:
/usr/local/bin/wkhtmltoimage /home/example/way/to/file/document.html document.png
Where example
this hosting account name.
When generating a PDF document, you can add a header and footer from separate HTML-files:
wkhtmltopdf --header-html <path to HTML header> --footer-html <path to HTML footer> <path to source HTML file> <path and name of output PDF file>
If necessary, you can set indents for PDF documents:
wkhtmltopdf --margin-top 25mm --margin-bottom 25 mm --margin-left 15mm --margin-right 15mm --header-html <path to HTML header> --footer-html <path to HTML footer> <path to HTML source file> <path and name of output PDF file>
Examples of other useful options for wkhtmltopdf:
–encoding windows-1251
- explicit indication of the source encoding HTML-file.–page-size A4
- the page format of the output PDF file.–orientation Landscape
- page orientation of the output PDF file.You can use utilities from PHP using the function exec.