https://github.com/suqingdong/md2pdf
A user-friendly tool for converting Markdown to PDF
https://github.com/suqingdong/md2pdf
markdown-to-pdf markdown2pdf md-to-pdf md2pdf
Last synced: 6 months ago
JSON representation
A user-friendly tool for converting Markdown to PDF
- Host: GitHub
- URL: https://github.com/suqingdong/md2pdf
- Owner: suqingdong
- Created: 2025-06-25T07:59:06.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-06-26T03:50:15.000Z (11 months ago)
- Last Synced: 2025-11-09T21:27:35.139Z (7 months ago)
- Topics: markdown-to-pdf, markdown2pdf, md-to-pdf, md2pdf
- Language: Python
- Homepage: https://suqingdong.github.io/md2pdf/
- Size: 460 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README


---
# A user-friendly tool for converting Markdown to PDF
## Installation
```bash
pip install md2pdf-python
```
## Usage
### Use in CMD
```bash
md2pdf --help
md2pdf tests/demo.md -o tests/output-default.pdf
md2pdf tests/demo.md -o tests/output-default.pdf --html
md2pdf tests/demo.md -o tests/output-styles.pdf --css-file tests/demo.css --mermaid-config tests/demo.json
```
### Use in Python
```python
from md2pdf.core.converter import MD2PDF
md2pdf(input_file='input.md', output_file='output.pdf')
md2pdf(input_file='input.md', output_file='output.pdf', html=True)
md2pdf(input_file='input.md', output_file='output.pdf', css_file='custom.css')
md2pdf(input_file='input.md', output_file='output.pdf', css_file='custom.css', mermaid_config='custom-config.json')
```
### Customize CSS
```css
body {
font-family: Arial, sans-serif;
font-size: 12pt;
}
h1 {
color: red;
}
h2 {
color: blue;
}
h3 {
color: green;
}
p {
color: black;
}
table {
border-collapse: collapse;
width: 100%;
}
```
### Customize Mermaid Config
```json
{
"theme": "default",
"themeVariables": {
"fontFamily": "Times New Roman, serif"
},
"backgroundColor": "#F2F2F2"
}
```
---
## Support Features
- [x] TOC
- [x] Table
- [x] Quote
- [x] Code Block
- [x] Inline Code
- [x] Image
- [x] Checkbox
- [x] Mermaid
**mermaid render** is based on [Mermaid-CLI (mmdc)](https://www.npmjs.com/package/@mermaid-js/mermaid-cli), install it with:
`npm install -g @mermaid-js/mermaid-cli`
---
## Demo
- INPUT: [demo.md](https://suqingdong.github.io/md2pdf/tests/demo.md)
- OUTPUT-DEFAULT: [output-default.pdf](https://suqingdong.github.io/md2pdf/tests/output-default.pdf)
- OUTPUT-STYLES: [output-styles.pdf](https://suqingdong.github.io/md2pdf/tests/output-styles.pdf)