How to convert HTML into endless one-page PDF via wkhtmltopdf?

The wkhtmltopdf 0.9.6 Manual documents this parameter :

    --page-height      <unitreal>      Page height (default unit millimeter)

Therefore defining an enormously long page can be done via :

--page-height 10000cm
--page-height 100m

which both define a page of height of 100 meters (I mention both in case your wkhtmltopdf does not support m).

Not using wkhtmltopdf, I do not know if there is some upper limit to page-height, but you can find that empirically.

In addition you can try to add --disable-smart-width (width is not an error) and try for the moment the less ambitious --page-height 100cm.

In this man page there is a comment about disable-smart-width that it's only available using patched QT.

There is also another comment:

On the wkhtmltopdf website you can download a static version of wkhtmltopdf at http://code.google.com/p/wkhtmltopdf/downloads/list. This static binary will work on most systems and comes with a build in patched QT.

The project has moved elsewhere, so you might hunt there for such a version, or ask in the forums.


You should do it as below:

$ wkhtmltoimage http://superuser.com/ superuser.png
loaded the Generic plugin 
Loading page (1/2)
Rendering (2/2)                                                    
Warning: Received createRequest signal on a disposed ResourceObject's NetworkAccessManager. This might be an indication of an iframe taking too long to load.
Done                                                               
$ geo=$(file superuser.png | awk '{print $5"x"$7}' | sed -e 's/,//')
$ convert superuser.png -page $geo superuser.pdf

Convert is performed from the ImageMagick package. The disadvantage of using the method above is that the PDF output would have a static image.


Looking again inside the code it seems you still cannot select an infinite roll.

So you can simply use the imagemagick command mogrify with the option -append on the downloaded file (or even +append if you want to append them horizontally).

wkhtmltopdf http://superuser.com/ superuser.pdf
mogrify -append superuser.pdf

from man mogrify

-append
append an image sequence top to botto (use +append for left to right)

If you want to create a new file you can use from the same suite convert.

convert -density 200 superuser.pdf -append superuser.vertical.pdf