A powerful Python package to convert Markdown files to PDF with syntax highlighting and emoji support.
uv add markdown-html-pdf
After installation, you need to install Playwright browsers:
uv run playwright install
Or use the built-in auto-installer on first run.
# Basic conversion
uv run markdown-html-pdf input.md output.pdf
You can also use the shorter alias:
uv run md2pdf input.md output.pdf
import asyncio
from markdown_html_pdf import markdown_to_pdf
async def convert():
await markdown_to_pdf(
markdown_file_path="input.md",
pdf_output_file_path="output.pdf"
)
asyncio.run(convert())
markdown-it-py
with GitHub-flavored Markdown supportInline code
and code blocks with syntax highlightingMIT License - see LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.