20061204

Concatenating PDFs

Dealing with pre-existing pdfs tends to be a pain, but concatenation is pretty simple. I like the Ghostscript option - I'll probably write a script to automate that over winter break.

gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf in1.pdf in2.pdf in3.pdf

The Ghostscript above didn't work well for me, but I had luck with the texexec command from the same page - just texexec -pdfarrange -result out.pdf in1.pdf in2.pdf [...] . If you want to add a blank page anywhere, use the --addempty=n flag, where n is a comma-delineated list of the pages after which you want an empty page. Note that for whatever reason, texexec will pad the end of your document with an empty page if you have an odd number of pages. If you don't want that, you can use the --noduplex flag, but why not print double sided and save a tree? Anyway, you need Ghostscript TexExec for this (duh). But if you're doing this on a machine with a decent commandline (and LaTeX), we can usually assume you have that. The page listed above also mentions ways of putting multiple pages on one sheet (like you often see with Powerpoints). Haven't tried it yet, but it looks simple. And I didn't have the performance issue mentioned on that page - it ran quickly for me. There's also a trick there to using TeX with a package called PDFpages. A bit more cumbersome, but it should work.

So, at oh-dark-thirty when you've finished your psets, scp them to athena; concatenate them; pdf2ps the resulting file; and you need only run one lpr command in the morning (if you want to be really ambitious, concatenate them on your local machine, and ssh into athena.dialup.mit.edu to run the lpr command as you walk out of your room - then your printout will be waiting for you as you pass the cluster).

No comments: