Forum How do I...?

... Add a Page To An Existing Prince'd PDF?

silverRocket
Hi there

I want to put two different XHTML webpages into a single PDF... I figured I'd create the first page/pdf (easy), then append the second webpage to the existing PDF.

Is this possible? I tried searching the forums, but couldn't see this anywhere... Tips? Thanks...
silverRocket
ps: I'd happily accept a PHP workaround, ie: create two PDFs and have PHP merge them into one somehow...
kmmv
Prince cannot do this by itself. However, there are plenty of tools that can.

I use pdftk, a free (GPL) open-source command line utility to do it, something like this:

pdftk document_1.pdf document_2.pdf cat output my_new_merged.pdf


Adobe Acrobat can do more advanced things such as rotating, cropping, etc. I'm not aware of a command-line utility that can do all that Adobe Acrobat can, but pdftk will get you started.
mikeday
Prince can also convert multiple input documents into a single PDF document, however this feature is not yet available in the PHP interface. You can try running Prince from the command-line like this:
$ prince doc1.html doc2.html -o output.pdf

It should be possible to extend the PHP interface to support this yourself if you're comfortable programming in PHP; we just haven't had time to do it yet.
silverRocket
Both excellent tips, thanks!