0

I'm using DOMpdf to generate PDF files, I'm able to generate 15 pages so far, however I need to be able to generate 130 pages, I know this might consume memory, so I'm looking for a way where I can generate each 10 pages in a separate process, and make all of them write to the same file. My question is, is that possible?

Mohamed Said
  • 4,413
  • 6
  • 35
  • 52

1 Answers1

2

There are many tools that can join PDFs together. One that I have had a lot of luck with is PDFtk Server. If you generate many small PDFs (e.g. 001.pdf, 002.pdf, 003.pdf) you can generate a joined PDF (e.g. final.pdf) with something like

pdftk cat 001.pdf 002.pdf 003.pdf output final.pdf

The page ordering of final.pdf will respect the order of the input files.

This is a standalone Java program, not a PHP library, so you'll have to kick the tool off with something like shell_exec or any number of other options.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • It seem to be a great solution, but I couldn't find a way to install it on Ubuntu, I'm running on Digital Ocean. – Mohamed Said Dec 21 '13 at 21:57
  • @MohamedSaid, `pdftk` is available in the universe repository for Ubuntu 13.10. You can enable this repository as outlined at http://askubuntu.com/questions/148638/how-do-i-enable-the-universe-repository – ChrisGPT was on strike Dec 21 '13 at 21:59