I’m trying to automate the process of taking a blog (or any collection of plain text and images) and producing a printed book, for reasons that will be stated elsewhere. These are my notes on doing so.
Working backwards: I’ll be using CreateSpace to print and bind the book. CS’s main inputs are 1) a PDF of the book’s cover and 2) a PDF of the book’s interior. I’ll figure out how to automate the creation of the cover later; for now I’ll focus on the book’s interior. I’ll be using pandoc to convert HTML or Markdown into LaTeX, which can then be used to generate the PDF. Most of the work will be in creating a suitable LaTeX template.
$ brew install pandoc
As a simple test, I took the plain tex of one of my own blog posts and saved it to
simplepost.txt. I also manually added some meta-data to the top (as described on pandoc’s user guide), like so:
--- title: Imagination and Self-Doubt author: Joel Dueck date: July 18, 2014 --- # Imagination and Self-Doubt ...
and then ‘compiled’ to PDF:
$ pandoc -s -o out.tex simplepost.pdf $ xelatex out.tex out.pdf
The result is a very basic PDF set in Computer Modern, suitable for printing on loose sheets of 8.5″ × 11″ paper:
In later notes I’ll be working on customizing the LaTeX template used by pandoc to get a good-looking PDF suitable for use with CreateSpace.