May 12, 2022    Share on: Twitter | Facebook | HackerNews | Reddit

Convert markdown to pdf

With pagination

convert with pandoc to pdf

pandoc \
--from=markdown \
--standalone \
--to=pdf \
--pdf-engine=xelatex \
--output=book.pdf \
--metadata title="My booklet"

Without pagination

# convert to HTML
pandoc \
--from=markdown \
--standalone \
--to=html \
--output=book.html \
--metadata title="My book title" \
--toc

# convert to pdf
wkhtmltopdf \
-B 5mm -T 5mm -L 5mm -R 5mm \
-s A5 \
book.html book_html.pdf

Experiment with page size to impact margins and font size

see: https://blog.scottlowe.org/2018/09/27/a-markdown-to-pdf-workflow-on-linux/