Generating a nice-looking PDF with Pandoc

Pandoc is one of my favourite tools in the world. If you haven’t come across it before, it converts between more or less any two document formats. I use it a lot with MarkDown and ReStructuredText so that I can produce content efficiently and then share it in a way that looks nice, but also to get word documents into cleaner formats. However the PDF output has always looked a little bit … dated? (this is rich from an rst2pdf maintainer I know!) and I was recently delighted to find some tricks that resulted in a better PDF. I’m sharing them here, so I can find them again in the future; you are welcome to use them too, of course! Continue reading

Make Thumbnails of PDF Pages with ImageMagick

All my talk slides are PDF – I use rst2pdf to transform text-based ReStructuredText content into presentation slides. With all these PDFs hanging around, it can be very handy to have them as thumbnails. I use the images both in the printable speaker notes that I produce (and I should blog that too now I’ve mentioned it), and to share on twitter – especially the resources slide that everyone photographs! My image file is much more readable than your cameraphone picture in terrible lighting :) So here’s my script for thumbnails in case you want to do the same; most presentation tools will export to PDF if you’re not already working in that format. Continue reading

Grab Annotations from a PDF with pypdf2

If you’ve noticed a lot of PDF content around here lately, that’s because I work with PDF a lot! Most of all, all my slide decks are in PDF and in the last year or so I’ve started using speaker notes in my presentations. Yes, this means that if you saw me speak in the first ten years of my speaking career, that was without speaker notes.

There are some situations where I don’t have access to my speaker notes. Usually this is a good reason, such as I have mirrored my displays so I can demo or play a video without fiddling with my display settings in the middle of a talk. Sometimes, it’s because something bad happened and I’m presenting from someone else’s machine or a laptop that’s completely off stage and I only have the comfort monitor. For those situations I use a printed set of backup speaker notes so I thought I’d share the script that creates these.

Continue reading

Presenting from PDF

I’ve been using PDF as a file format for presentations for the last ~8 years and I LOVE it. The clue is in the name: Portable Document Format: it’s an open standard, and works everywhere. You can embed your fonts, images, whatever … if you end up presenting it from another machine for some reason, everything is going work, even when you want to upload the slides afterwards. Yet, it’s still a pretty unusual choice, I think because people don’t know much about the tooling around it – so I thought I’d share some of my tips.

Today: tools for actually delivering a PDF presentation (I make them with rst2pdf ). Continue reading

Scaling and Sizing with PDFJam

I find myself needing to take a PDF, output it at a specific size, and have the result offset to the top right hand side of the screen. To achieve it, I needed a few new switches to my good friend PDFJam, so I thought I’d share my command!

pdfjam --suffix converted --papersize '{1920px,1080px}' --scale 0.4 --trim "-6cm -1cm 13cm 8cm" slides.pdf

The --suffix is instead of giving an output filename, whatever you feed in ends up with the suffix in its filename. This is very handy because I use this command in a script and only need to pass in one variable. The --papersize isn’t a switch I have used before either but you can set exact sizes for the final output which is nice. The --trim switch can also be used to set --clip=true to remove the trimmed space from the document if desired.

I find PDFJam a very handy tool but with not nearly enough blog posts and code snippets around, so I’m dropping my command for future reference (yours as well as mine!).

Splitting And Combining Odd/Even Pages With Pdftk

I’m working on a fun printable project at the moment, but part way through I realised I would need to process odd and even pages of the document separately. So separately, that I split the doc into two separate ones, with odd pages in one and event pages in another – and then had to recombine them. Here’s the commands that I used, with an excellent tool called pdftk. Continue reading

Hiding Sections With Rst2pdf

I’ve been using rst2pdf for slides for a year or so, but recently I’ve been converted to using it for everything from documents to emailed reports to handouts. Along the way there were a couple of cases where I wanted to create two similar documents, but one needed to omit some details. A great example is my ZCE questions pack, which when updated to PHP 5.5 I converted to restructuredText. By showing/hiding different sections of the document when I generate the PDF, I can maintain the questions and their answers side-by-side, then create the documents containing questions and answers separately. You could do the same with adding a notes field to slides that are hidden when presenting, but available for handouts. Continue reading

Printing Many PDFs Per Page

Much of my work revolves around documents or slides, and I use PDF format for pretty much everything I do. In the last year or so I’ve developed a love affair with rst2pdf which means I’m doing more PDF now than ever.

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.

Printing PDF Bookmarks List

I work with PDF a lot, and it bothers me that I can see an outline view when I open the document, but I don’t seem to be able to grab just that view. My presentations are mostly PDF and the titles and section headings show up nicely. Today I figured out how to get an outline view, so I’m putting that information here while I remember how to do it!

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.

Lesson Learned: Look in the Pull Request Queue

If you follow me on twitter you might have seen some overexcitement when I managed to edit and compile a vala application recently. I use a great deal of open source tools, but many of them don’t seem open to me, because I don’t have the skills to modify the code. Regardless of that, it’s still vitally important that it is open (this is a whole other post and I’ll avoid that tangent right now). Continue reading