This weekend I was working on a project which needed a programatically-generated PDF file to be many-slides-per-page – and for this I adopted a tool I haven’t used before: pdfjam (installed straight from apt on Ubuntu).
In fact it was pretty easy to get going with it: to print my existing PDFs at 4-per-page, I used this command:
pdfjam --landscape --nup 2x2 --a4paper -q slides.pdf -o handout.pdf
The slides themselves were already landscape so I specified the target document should also be landscape. The
--nup 2x2 is the magic that prints many slides per page, and it seems like it can do various nice tricks with handouts. Running through the other arguments that I used:
--a4paper for the paper size,
-q to stop it from chattering (which it does by default, even when everything worked),
slides.pdf was my input file and
-o handout.pdf the target file to put the new layout into.
Until now I’ve mostly worked with pdftk for everything, but I couldn’t find a way to do this using it. Pdfjam is now a welcome addition to my PDF toolchain, so I thought I’d share.
I used a tool called pdftk which is excellent, I’ve used it before for doing various other PDF-related things. To grab metadata such as bookmarks, use the dump-data command, like this:
pdftk myfile.pdf dump_data | grep BookmarkTitle > outline.txt
The above line takes all the bookmarks from the PDF (this was a slide deck created using powerdot and LaTeX, the section and slide titles nest appropriately), and outputs a bunch of information about the document and the various PDFs. The
grep command just gets the lines containing “BookmarkTitle”, then the whole thing gets written to a file. I cleaned that up and now I have the outline of my course, so I can add timings, notes for the exercises and so on.