2022-05-12
Convert Markdown to PDF
X::[[pandoc]] X::[[writing_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"
alternative pdf-engines: - typst - pdflatex - ...
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
You can install wkhtmltopdf using brew:
brew install wkhtmltopdf
See also
- A Markdown-to-PDF Workflow on Linux - Scott's Weblog - The weblog of an IT pro focusing on cloud computing, Kubernetes, Linux, containers, and networking
- [[convert_html_to_markdown_with_pandoc]]
Tags:
conversion
markdown
pdf
pandoc
wkhtmltopdf
html