Markdown Files to PDF
Convert Markdown documents to PDF with my script.
Requirements
- A
md-to-pdf-generatorscript. Contact me on how to get. - A markdown file with correct header.
- Docker.
- AWS ECR Login.
Quick Start Guide
Get the Script
Get the script in my author directory under scripts/md-to-pdf-generator. Copy it to your bin/ directory.
This is a python script built on Linux platform. It will only work on Linux platforms.
Create a .md File
Create a markdown file somewhere on your system, we'll call it example.md.
Now we will add header which should look something like this. See Eisvogel template for more headers.
Your example.md file should look like this:
---
title: "Example"
date: "__DATE__"
keywords: [Example]
titlepage: true
titlepage-text-color: "588DD2"
titlepage-rule-color: "588DD2"
titlepage-rule-height: 2
titlepage-logo: "/logo/logo-small-light.pdf"
logo-width: 30mm
toc: true
toc-own-page: true
table-use-row-colors: true
listings-disable-line-numbers: false
footnotes-pretty: true
header-right: "\\includegraphics[width=5mm]{/logo/logo-small-light.pdf}"
footer-left: "Observit © __YEAR__"
header-includes: |
\usepackage{sectsty}
\usepackage{xcolor}
\definecolor{sectioncolor}{RGB}{88,142,210}
\definecolor{subsectioncolor}{RGB}{88,142,210}
\definecolor{subsubsectioncolor}{RGB}{88,142,210}
\sectionfont{\color{sectioncolor}\clearpage}
\subsectionfont{\color{subsectioncolor}\clearpage}
\subsubsectionfont{\color{subsubsectioncolor}}
...
# This is Example Title
Example body.
Save it.
NOTE: __DATE__ and __YEAR__ varaibles are filled by script automatically. Script also takes care of the images, you do not need to care about logo-small-light.pdf.
Get Available Tags
Run script with --list-tags to get available docker images.
$ md-to-pdf-generator --list-tags
2024-06-10 16:42:51 [INFO]: Listing image tags...
2024-06-10 16:42:55 [INFO]: Available tags:
1.0
latest
2.0
Get Logos
Old logos are available in /logo/ directory. They are available in all images.
/logo/$ ls
logo-small-dark.pdf logo-small-dark.svg logo-small-light.pdf logo-small-light.png logo-small-light.svg
New logos can be found in /logo-2024/ directory. New logos are available in docker images version >=2.0.
/logo-2024/$ ls
Observit-black-dot.pdf Observit-short-black-dot.pdf Observit-short-white-dot.pdf Observit-white-dot.pdf
Observit-black.pdf Observit-short-black.pdf Observit-short-white.pdf Observit-white.pdf
Generate PDF from .md File
- See help if needed.
md-to-pdf-generator -h
usage: md-to-pdf-generator [-h] [-v] filename
Convert Markdown to PDF using Pandoc in Docker.
positional arguments:
filename The Markdown file to convert.
optional arguments:
-h, --help show this help message and exit
-v, --verbose Enable verbose output.
- Generate PDF
md-to-pdf-generator example.md
- See generated file, always filename_datum.pdf