2022-05-12    Share on: Twitter | Facebook | HackerNews | Reddit

Convert Markdown to PDF

X::Writing a Book or Ebook Using Pandoc

Without ToC

convert with Pandoc to PDF

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

With ToC

# 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

NOTE: Experiment with page size to impact margins and font size

See also