Recently I was compiling a booklet of devotions for a mission trip. My goal was to make a simple booklet using standard paper, printed double-sided, and folded down the middle. I looked online for options and kept finding web-based tools that looked like overkill. I wanted a simple text booklet - no splashy template, no color, no images.
I had heard of Pandoc and PDFJam before and decided to give them a try. The tools worked really well for my use case. I thought I’d share what worked for me as it took me a bit to figure out, not having any prior experience with these tools.
Tools
- Pandoc is a “universal document converter.” I used it to go from Markdown to PDF but it can convert to and from an amazing number of document formats.
- PDFJam is a tool for manipulating PDFs. I used it to create a “booklet” PDF, where the pages were properly arranged for printing a booklet.
Step 1: Process Markdown files
I had nine days of devotions and rather than store them in one large Markdown file, I wanted to put each in its own Markdown file. Originally I received them as nine Word documents. Perhaps I could have used Pandoc to process the Word documents themselves but I also liked the idea of representing each devotion in Markdown. I love plain text formats.
I wrote a small Python script to process these files; for instance, I wanted to add the LaTeX \newpage
command before each devotional, except the first one; and I had a few other small transformations I wanted to do.
This Python script generated a single Markdown file from the other nine, and I could feed this into the next step.
Step 2: Convert Markdown to PDF
The second step was the conversion of the single Markdown file into a PDF. Here is the command I used:
pandoc config.yaml build/intermediate.md -o build/intermediate.pdf --pdf-engine=xelatex
And here is my config.yaml file:
---
title: Team Devotions
author: Name of Author
documentclass: book
classoption: 14pt
header-includes:
- \usepackage{extsizes}
- \usepackage{geometry}
- \geometry{a5paper, margin=0.8in}
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \fancyhf{}
- \fancyhead[C]{Team Devotions}
- \fancyfoot[C]{\thepage}
- \renewcommand{\headrulewidth}{0pt}
---
There are several things in here that took me a while to learn, including:
- There is a
documentclass: book
option, with some nice defaults like a cover page. - Only certain font sizes are supported. Other sizes fail with a warning and resolve to a default font size. I chose
14pt
because smaller fonts didn’t seem big enough after the final processing step. - The order of
header-includes
matters; for instance, it’s important to set the geometry before centering the header text, so that the header text is centered based on the actual final paper size and not the default paper size.
Step 3: Creating a Booklet PDF
At the end of step 2, I had a nicely formatted PDF that I could share with my team and would be great for digital viewing, but I hadn’t figured out how to print it as a booklet.
Ultimately, I used PDFjam with a command like this:
pdfjam --booklet true --landscape --suffix booklet --paper letterpaper --outfile build/booklet.pdf build/intermediate.pdf
The resulting PDF was ready to print double-sided to create my booklet. PDFJam took care of combining every two pages of the intermediate PDF into a single page of the final PDF, and it also correctly laid out the pages so that the front and back of the booklet were on one side of a single page, etc.
Note: I’ve since learned that sometimes you can generate the booklet through your print dialog, but it was still appealing to me to have a PDF of letter-size paper that represented the booklet.
Reflection
I was really happy with the final output from this project! The booklet looked clean and professional. I also enjoyed learning some new tools that I expect will be useful again in the future. I also hope this write-up helps someone else create a booklet!