Tool to convert Markdown files to PDF using Python.
- Python 3.7+
- Install dependencies:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -r requirements.txtRun without arguments to open the graphical interface:
python src/main.pyConvert a file (output name inferred from input):
python src/main.py data/report.mdSpecify output file explicitly:
python src/main.py data/report.md output.pdfInclude a custom CSS file:
python src/main.py data/report.md --css mystyle.cssQuiet mode:
python src/main.py data/report.md -qRequires PyInstaller:
pip install pyinstallerThen build a single .exe:
pyinstaller --onefile --windowed --name espasmo --collect-all xhtml2pdf --collect-all reportlab src/main.pyThe executable will be at dist/espasmo.exe.
| Flag | Description |
|---|---|
--onefile |
Bundles everything into a single .exe |
--windowed |
Suppresses the console window when using the GUI |
--collect-all xhtml2pdf |
Includes internal fonts and CSS from xhtml2pdf |
--collect-all reportlab |
Includes ReportLab font data required by xhtml2pdf |
dist\md2pdf.exe # opens the GUI
dist\md2pdf.exe data\report.md # CLI mode- Relative image paths in the Markdown are resolved relative to the Markdown file location.
- Images are auto-scaled to fit A4 width (655 px at 96 dpi).
- If PDF fonts or styling look off, try a custom CSS with web-safe or embedded fonts.