For many years, wkhtmltopdf was the best available option. mPDF is vastly superior. wkhtmltopdf remains an optional available to Tiki, and thus, the information below is kept.
wkhtmltopdf
wkhtmltopdf is an open source (LGPLv3) command line tool (Simple shell utility) to render(convert) HTML into PDF using the QT Webkit rendering engine. It runs entirely "headless" and do not require a display or display service. There is also a C library.
Source: http://wkhtmltopdf.org
There are two options (wkhtmltopdf 0.13 aims to simplify this)
- standard: fewer features, requires X (and if your GNU/Linux OS is virtualized, it perhaps won't work)
- patched QT: more features, doesn't require X (headless)
OpenHub
Configure
To configure with Tiki, go to General » General Settings admin panel (tiki-admin.php?page=general&cookietab=2) and set "PDF from URL" to "WebKit (wkhtmltopdf)". Then in the "WebKit path" insert for example this full path to the executable file: /var/local/bin/wkhtmltopdf-amd64
(on a Linux 64-bit system, the path can be different depending on the installation).
which wkhtmltopdf
/usr/local/bin/wkhtmltopdf
Installation for various operating systems
- http://wkhtmltopdf.org/downloads.html
- ClearOS:
- v 0.12.x: http://old.clearfoundation.com/docs/howtos/wkhtmltopdf (which will be very similar in CentOS)
- v 0.13.x:
- Get the rpm from here: http://wkhtmltopdf.org/downloads.html
e.g.: https://bitbucket.org/wkhtmltopdf/wkhtmltopdf/downloads/wkhtmltox-0.13.0-alpha-7b36694_linux-centos7-amd64.rpm - Add the missing dependencies (for ClearOS 7.x):
yum install libXext icu xorg-x11-fonts-75dpi xorg-x11-server-Xvfb
- Install the package (for ClearOS 7.x, adapt file name to your case):
rpm -Uvh wkhtmltox-0.13.0-alpha-7b36694_linux-centos7-amd64.rpm
- Test the program (prepend xvfb-run to the program call):
xfvb-run wkhtmltopdf http://wkhtmltopdf.org/ wkhtmltopdf-test.pdf
Therefore, you need to tweak the file ./lib/pdflib.php to prepend the command with xvfb-run in front of$quotedCommand -q $arg $quotedFilename
, to leave that part like:
- Get the rpm from here: http://wkhtmltopdf.org/downloads.html
(...) /** * @param $url * @return mixed */ private function webkit( $url ) { (...) // Run shell_exec command to generate out file // NOTE: this requires write permissions $quotedFilename = '"'.$filename.'"'; $quotedCommand = '"'.$this->location.'"'; `xvfb-run $quotedCommand -q $arg $quotedFilename`;
Issues
- There might be problems for incorporating images or external content to the pdf file. Please see the wkhtmltopdf documentation.
- If you are having issues with password protected pages, trying activating Token Access
Collection of References on doc.tiki.org
- Print general info about printing
- PDF general overview about PDF creation in Tiki
- mPDF create PDFs from Tiki content (advanced library that works even on shared hosting). Recommended for Tiki18+
- PluginPDF alter default settings of mPDF per wiki page
- PluginPDFPageBreak add a page break for PDFs created with mPDF
- PluginMediaPlayer display PDF file from file gallery
- PDF.js viewer PDF.js from Mozilla
- ViewerJS: a script to view PDFs and ODFs, which bundles WebODF
- PluginArchiveBuilder Generate a zip file, including PDFs from wiki pages
- WeasyPrint A PDF generation option in Python
- wkhtmltopdf create PDFs from Tiki content (needs root installation)
- dompdf once used for PDF print of slideshows