Generating a PDF file with Pandoc and Docker
Last week I started with the Python Certification course on
freeCodeCamp. I keep notes on paper
which I transfer later to a Markdown file using vim.
I wanted to convert this Markdown file to a PDF file using Pandoc. Because I have already Docker running on my Mac mini I checked if there was an official Docker image.
I first tried the Pandoc
minimal image. I ran into
an issue: Permission denied. Adding -v /tmp:/tmp to the command
solved this issue, but now it reported 'pdflatex' not found. This
version was too minimal!
So, next I tried the aptly named latex image as follows:
docker run --rm \
-v "$(pwd):/data"\
-u $(id -u):$(id -g) \
pandoc/latex freecodecamp.md \
-o freecodecamp.pdf &&
open freecodecamp.pdf
This downloaded the image (only the first time), generated the PDF and opened the PDF file in the Preview application on macOS.