Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Markdown to PDF Converter

A Python tool to convert Markdown files to PDF format. Supports single-file and batch conversion.

Author: Amir Yunus

For a summary of changes by version, see CHANGELOG.md.

Features

  • Convert a single Markdown file to PDF
  • Batch convert multiple Markdown files in a directory (recursive, includes subdirectories)
  • Simple command-line or programmatic usage

Requirements

  • Python 3.10+
  • Dependencies: see requirements.txt

The script uses WeasyPrint when possible (best layout and typography). If WeasyPrint’s system libraries (Pango, Cairo, GLib) are not installed, it automatically falls back to xhtml2pdf (pure Python), so conversion works without extra system setup. On macOS you may see a WeasyPrint warning and then conversion will proceed with the fallback.

To use WeasyPrint and remove the warning (optional, for better PDF quality):

  • macOS: brew install pango cairo glib
  • Linux: install libpango-1.0-0, libcairo2, and related packages per your distribution

Installation

Using a virtual environment is recommended:

conda create --prefix venv python=3.11 -y
conda activate ./venv
python -m pip install -r requirements.txt

Usage

Single file

Convert one Markdown file to PDF:

python convert.py document.md

Output: document.pdf in the same directory (or as specified).

Batch conversion

Convert all Markdown files in a directory (recursively, including subdirectories):

python convert.py --batch ./markdown-folder

Or with an explicit output directory:

python convert.py --batch ./markdown-folder --output ./pdf-output

Project structure

  • convert.py — main conversion script (single and batch)
  • requirements.txt — Python dependencies

License

This project is licensed under the terms of the LICENSE file.

About

A Python 3.10+ tool for converting Markdown to PDF. Supports single-file and batch conversion, uses WeasyPrint when available and falls back to xhtml2pdf otherwise. Simple CLI and programmatic API.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages