I'm trying to write a script that takes as its input one PDF file containing a header block, plus one multi-page PDF file containing black and white vector graphics plus a little text, and outputs another PDF file where each page in the output consists of the header block over (or under or next to) a grid of six cells, and each cell contains a reduced-size copy of one page from the multi-page input file (perhaps cropped a bit).

The closest I've gotten was using the "montage" command of ImageMagick. The problem I had was that ImageMagick rasterizes all its input before it does anything else, and so by the time I got up to even just four or five pages of output at the resolution I need, it was taking my workstation over a minute to do the work, and the resulting file was 130MB, which is a ridiculous waste of resources. And even then, the line drawings suffered from aliasing.

I've looked into Ghostscript, but it seems oriented toward experienced electronic typesetting professionals. There isn't even a book available to pay for--just a cryptic, 20-page whitepaper that seems intended for people who already know how to use Ghostscript. I'd rather not spend a week learning the finer points of GS9 Color Management and the LaTeX format only to find out that Ghostscript can't do what I'm looking for. So, am I at least on the right track? QPDF was too limited in its feature set and MuTool is meant for a different problem domain--unless I'm mistaken.

The platform is a Windows server. I couldn't say what the budget might be. This is an oddball project-let that's part of a much larger CAD/CAM integration project I'm doing. It's fairly low priority--or at least, it will be until the boss sees how much we're spending on paper ;-)


1 Answer 1


You should definitely take a look at PDFtk pro & server. (The pair will cost you $3.99).

  • The pro edition is a GUI that allows a lot of control
  • The server edition is the command line back end of the pro-edition.

They will allow you to:

  1. Merge PDF Documents or Collate PDF Page Scans
  2. Split PDF Pages into a New Document
  3. Rotate PDF Documents or Pages
  4. Decrypt Input as Necessary (Password Required)
  5. Encrypt Output as Desired
  6. Fill PDF Forms with X/FDF Data and/or Flatten Forms
  7. Generate FDF Data Stencils from PDF Forms
  8. Apply a Background Watermark or a Foreground Stamp
  9. Report PDF Metrics, Bookmarks and Metadata
  10. Add/Update PDF Bookmarks or Metadata
  11. Attach Files to PDF Pages or the PDF Document
  12. Unpack PDF Attachments
  13. Burst a PDF Document into Single Pages
  14. Uncompress and Re-Compress Page Streams
  15. Repair Corrupted PDF (Where Possible)

For more flexibility but a steeper learning curve you can also look at ReportLab where you will find both commercial and open source solutions. If you would like to go the open source solution I can recommend Michael Driscolls book ReportLab PDF Processing with Python as a great primer.

N.B. Both PDFtk & python+ReportLab are cross platform so OS shouldn't be an issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.