md2pdf is an offline, isolated Markdown to PDF and DOCX conversion toolkit designed for fast, reliable documentation workflows with full support for Mermaid diagrams, SVG assets, and batch processing.
It was built to remove dependency on online tools and token-based AI conversions, and to provide a deterministic, local, and reproducible documentation pipeline.
No installation required. Fully offline.
Extract → Run md2pdf.exe → Convert
- Download and extract the ZIP
You will see:
md2pdf.exe
md2pdf.ico
ms-playwright/
- Run:
<!-- -->
md2pdf.exe
- Select your Markdown file
Done.
Generated in same folder:
PDF/
DOCX/
Do NOT delete:
ms-playwright/
No installation required. Fully offline.
Linux release coming soon.
Markdown has become my primary format for documentation because of its speed, simplicity, and compatibility with tools like:
-
VS Code with Markdown Preview Enhanced https://marketplace.visualstudio.com/items?itemName=shd101wyy.markdown-preview-enhanced
-
Obsidian
-
ChatGPT and Gemini for drafting and refinement
For rendering and exporting, I previously relied on online tools such as:
These worked well until I encountered a real-world constraint while traveling: the services were unavailable when I needed to deliver documentation urgently.
This exposed several limitations:
- Dependence on internet connectivity
- Service downtime risk
- Lack of batch automation
- No isolated, reproducible environment
- Wasted time and compute tokens for simple format conversion
This led to building a fully offline solution.
The goal was simple:
A fast, reliable, offline Markdown conversion tool that produces:
- publication-quality PDF
- editable DOCX
- full Mermaid support
- full SVG support
- batch conversion capability
- isolated bootstrap environment
This project is the result of that effort.
md2pdf follows these principles:
- Offline-first
- Deterministic output
- Fully isolated runtime
- No global dependency pollution
- Bootstrap-and-run architecture
- Minimal user friction
- Reproducible documentation pipeline
Each script version creates its own virtual environment and runs within it automatically.
No manual activation required.
The project evolved through four major iterations.
Each iteration was an MVP designed to validate a specific part of the pipeline.
Initial proof-of-concept.
Single file conversion using local rendering.
Workflow:
flowchart LR
A[Markdown File] --> B[Convert to HTML]
B --> C[Render via Chromium]
C --> D[Export PDF]
Limitations:
- Single file only
- No Mermaid support
- No SVG support
- No DOCX
Added GitHub-style rendering and Mermaid support.
Workflow:
flowchart LR
A[Markdown] --> B[HTML Conversion]
B --> C[Inject GitHub CSS]
C --> D[Inject Mermaid Engine]
D --> E[Chromium Render]
E --> F[PDF Export]
Improvements:
- GitHub-style output
- Mermaid rendering
- SVG rendering
Limitations:
- Single file conversion
- No DOCX export
Added multi-file selection and batch processing.
Workflow:
flowchart LR
A[Multiple Markdown Files] --> B[Loop Through Files]
B --> C[Render HTML]
C --> D[Chromium Render]
D --> E[Export PDF]
Improvements:
- Batch conversion
- Stable rendering
Limitations:
- No editable format output
Full production workflow.
Supports:
- Batch conversion
- PDF export
- Editable DOCX export
- Mermaid rendering
- SVG rendering
- Asset support
- Isolated bootstrap
Complete workflow:
flowchart TD
A[Markdown Files]
A --> B[Bootstrap Virtual Environment]
B --> C[Convert Markdown to HTML]
C --> D[Inject GitHub CSS]
D --> E[Inject Mermaid Engine]
E --> F[Render using Chromium]
F --> G[Export PDF]
F --> H[Extract Rendered Elements]
H --> I[Convert Mermaid to PNG]
H --> J[Convert SVG to PNG]
H --> K[Extract Editable Text]
I --> L[Build DOCX]
J --> L
K --> L
L --> M[Output DOCX]
For a Markdown file:
project/
README.md
Output:
project/
PDF/
README.pdf
DOCX/
README.docx
Text remains editable.
Mermaid diagrams are inserted as images.
SVG diagrams are inserted as images.
Layout remains clean and usable.
For best compatibility and predictable rendering, it is recommended to store SVG files inside an assets folder located in the same directory as the Markdown file.
Recommended structure:
project/
README.md
assets/
architecture.svg
flow.svg
Reference inside Markdown:

This approach follows the same rendering strategy used by GitHub README rendering.
Benefits:
- consistent rendering across GitHub, VS Code, and md2pdf
- no broken image paths
- fast local rendering
- clean project organization
- easier portability and sharing
This design decision was inspired directly by GitHub’s README rendering flow, ensuring the exported PDF and DOCX match the same visual output seen in repository documentation.
Clone repository:
git clone https://github.com/855princekumar/md2pdf.git
cd md2pdfRun:
python md-to-pdf-docx.pyThe script will:
- create isolated environment
- install dependencies
- launch conversion tool
No setup required.
Markdown features:
- headings
- tables
- code blocks
- lists
- images
Diagram support:
- Mermaid
- SVG
Output formats:
- DOCX
Processing modes:
- single file
- batch conversion
Platforms:
- Windows
- Linux
Each script in this repository represents a tested stage of the pipeline.
These versions are preserved intentionally to provide:
- architectural reference
- experimentation base
- customization starting point
Users can modify or extend any stage.
Typical workflow:
Write documentation in:
- Obsidian
- VS Code
- ChatGPT
- Gemini
Preview locally.
Run md2pdf.
Export:
- distribution-ready PDF
- editable DOCX for team collaboration
This tool exists to eliminate:
- dependency on online converters
- downtime risks
- token-based conversion waste
- formatting inconsistencies
- manual conversion overhead
It acts as a local documentation Swiss-army knife.
md2pdf/
md-to-pdf-docx.py
version-history/
examples/
README.md
The repository also contains the full architectural evolution history:
md2pdf/
├── 1-beta-version/
│ └── md-to-pdf.py
│
├── 2-half-render-version/
│ └── md-to-pdf.py
│
├── 3-full-render-version/
│ └── md-to-pdf.py
│
├── 4-DOC+PDF-full-render/
│ └── md-to-pdf.py
│
└── README.md
Final production version:
4-DOC+PDF-full-render
This contains the complete rendering pipeline.
Primary documentation workflow uses:
VS Code Markdown Preview Enhanced:
https://marketplace.visualstudio.com/items?itemName=shd101wyy.markdown-preview-enhanced
This extension allows:
- live preview
- Mermaid rendering
- project-folder documentation workflow
Typical workflow:
Write Markdown
↓
Preview in VS Code Extension
↓
Convert using md2pdf
↓
Share PDF or DOCX
This ensures:
- consistent rendering
- fast export
- offline reliability
- team-friendly sharing
Team members can either:
- use the extension
or
- use exported PDF / DOCX
Standalone builds are also provided for direct use.
No Python installation required.
Available:
Windows:
md2pdf.exe
Linux:
md2pdf.tar.gz
Workflow:
Launch Tool
↓
Select Markdown File
↓
Click Convert
↓
PDF and DOCX Generated
Output:
PDF/
DOCX/
This makes it ideal for:
- engineering teams
- offline systems
- production documentation
- non-technical users
Planned:
- executable build
- drag-and-drop interface
- folder watch mode
- CI integration
- CLI arguments
MIT License
md2pdf was built out of necessity during real-world constraints.
It has since become part of my daily documentation workflow.
Using VS Code with Markdown Preview Enhanced and exporting via md2pdf has created a complete offline documentation pipeline.
If you work heavily with Markdown, especially with diagrams and structured documentation, this tool is designed to make your pipeline faster, reproducible, and independent.