Today I finished a project I have been working on over the last couple months. I've compiled a lot of my knowledge with I've gained over the last year into a GitHub repository, and created a document using Python 2.7 and pandoc, a free and open source tool for converting documents between common types.
Markdown is a markup language that translates directly into HTML. I wrote units using the language for each module from the assistant technical director apprenticeship standard.
build_pdf.py
compiles a pdf using these documents.
The solution I came up with works in 4 stages:
- The
.md
(Markdown) units are compiled into a single monolithic Markdown file (./md/out.md
). - Images from
./image_orig/
are shrunk to a hardcoded width usingffmpeg
and are moved to./images/
. (This makes the PDF lighter.) - This file is then converted to a LaTeX file (
./tex/out.tex
), another markup language, which gives me more control of the formatting. - Python fixes are run on this file which I have written, which adjust the formatting to my tastes. (i.e. Titles are added, page breaks are added before new sections and at specific points I've specified.)
- The pdf is generated by pandoc (
./pdf/out.pdf
).
When you run ./build_pdf.py
you have the option of which task to run.
[hbal@terminal6 atd-apprentice-module-summaries]$ python2.7 build_pdf.py
1 md -->md + Shrink Images
2 md_compiled-->tex + Run Fixes
3 tex_compiled-->pdf
0 Run All
>>>
I've also created a booklet version (./pdf/booklet.pdf
) which makes for an easier way to read this. This can be created by printing 2 pages each on each side of landscape double-sided paper (flip on the short-edge) in this order:
60, 1, 2, 59, 58, 3, 4, 57, 56, 5, 6, 55, 54, 7, 8, 53, 52, 9, 10, 51, 50, 11, 12, 49, 48, 13, 14, 47, 46, 15, 16, 45, 44, 17, 18, 43, 42, 19, 20, 41, 40, 21, 22, 39, 38, 23, 24, 37, 36, 25, 26, 35, 34, 27, 28, 33, 32, 29, 30, 31
(This sequence was generated with ./booklet_pages.py
)
Thanks for reading.