My favorites | Sign in
Project Logo
                
Feeds:
People details
Project owners:
  antialize
Project committers:
marricardo

Description

Simple shell utility to convert html to pdf using the webkit rendering engine, and qt.

Introduction

Searching the web, I have found several command line tools that allow you to convert a HTML-document to a PDF-document, however they all seem to use their own, and rather incomplete rendering engine, resulting in poor quality. Recently QT 4.4 was released with a WebKit widget (WebKit is the engine of Apples Safari, which is a fork of the KDE KHtml), and making a good tool became very easy.

ChangeLog

v0.8.2

v0.8.1
  • Static Linux version no longer requires X11
v0.8.0
  • Added support for changing default input encoding (static binary only)
  • Added support for supplying user style sheet
v0.7.5
  • Fixed bug with proxy not working as it should
  • Added proxy information to the man page
  • Corrected some spelling
v0.7.4
  • Fixed bug: stdin input does not work, stdout does not work on windows
  • Fixed bug: minus not minus on a man page
v0.7.2
  • Fixed bug: Unable to compile with CMake
  • Default to printing in screen media-type, switch added to restore old default paper (static binary only)
  • Added an experimental windows executable
  • Fixed bud: Logic invertion in --disable-javascript
v0.7.1
  • Fixed bug: h1 and h6 not included in outline
  • Fixed bug: Page calculation not correct for none toplevel h1 tags
  • Fixed bug: Outline page coordinates are wrong (and inverted)
  • Fixed bug: Outline depth setting has no effect
v0.7.0
  • Added support for pdf outlines (static version only)
  • Added support for cover pages (static version only)
  • Added support for Table of Contents (static version only)
  • Added support for putting multiple files into one pdf (static version only)
  • Extensive rewrite of the argument parsing code
  • Several arguments have been renamed
  • Added support for disabling javascript

v0.6.4

  • Fix a bug regarding writing pages to stdout
  • Fixed spelling

v0.6.2

  • Fixed bugs regarding header and footer line in static build
  • Made the qmake file generate and install manpage
  • The Source tarball now actually contains the source

v0.6.1

  • Added a manpage
  • Fixed bug that disabled local page support
  • Update: The static binary has now been fixed.

v0.6

  • Added support for headers and footers (static binary only)
  • Added support for js-redirects
  • More code documentation added
v0.5
  • Added support for reading command line options from stdin, to do multiple conversions fast.
  • Added options to set page margins.
  • Now shipping a binary statically compiled against QT4.5rc1, that shuld run as is on just about any Linux System.
v0.4
  • Added support for generation deb packages
  • Added option for dpi, low resolution and grayscale
  • Added (untested) support for removing background image when running under QT 4.5

v0.3

  • Added support for printing sites with self signed certificates
  • Added options for pageSize and orientation

v0.2

  • Added proxy support
  • Commandline parsing and quiet support

v0.1.1

  • Initial release

How to install

Ubuntu GNU/Linux

If you are using some kind of GNU/Linux distribution, and are the luck owner of a i386 or amd64 CPU. You can download the static binary. You will not need to install anything, just unpack and run.

Anyone else

If you are using some king of obscure CPU, or OS (e.g. windows) you will have to compile qtwkhtmltopdf on your own, you will need to install QT4.4 or above one way or another.

First you must install qt, on Linux like system this can be done as follows

wget http://wftp.tu-chemnitz.de/pub/Qt/qt/source/qt-all-opensource-src-4.4.3.tar.bz2
tar xf qt-all-opensource-src-4.4.3.tar.bz2
cd qt-all-opensource-src-4.4.3
./configure && make && sudo make install

Then you must compile wkhtmltopdf, download the latest source package and do as follows

qmake
make

If you like you can now copy the wkhtmltopdf file to /usr/bin

Note this only works on none Windows platforms. As the code is written using QT and qmake or CMake it should be easy to compile on Windows, but as I do not own a copy of the said OS, I cannot tell you how.

If you want to use the header/footer features of wkhtmltopdf you will need to apply the patches found in the source tarball to qt before compiling

Usage

To convert a remote HTML file to PDF: wkhtmltopdf http://www.google.com google.pdf

To convert a local HTML file to PDF: wkhtmltopdf my.html my.pdf

You can also convert to PS files if you like: wkhtmltopdf my.html my.ps

Help

If you have any problems or comments please feel free to contact me: see http://www.daimi.au.dk/~jakobt/#about

Ubuntu compile

#If you are running hardy you need to enable the backports, 
#This IS NOT NEEDED FOR 8.10, 
cat > /etc/apt/sources.list <<EOF
deb http://archive.ubuntu.com/ubuntu hardy-backports main restricted multiverse universe
deb-src http://archive.com/ubuntu hardy-backports main restricted multiverse universe
EOF

aptitude update
aptitude install libqt4-dev qt4-dev-tools build-essential cmake

svn checkout http://wkhtmltopdf.googlecode.com/svn/trunk/ wkhtmltopdf
cd wkhtmltopdf
cmake -D CMAKE_INSTALL_PREFIX=/usr .
make
sudo make install








Hosted by Google Code