A Python program that converts Markdown files to professional PDFs. Includes custom CSS support and emoji support.
- π₯οΈ Graphical Interface (GUI): User-friendly graphical interface
- π» Command Line: Use from terminal
- π¨ Custom CSS Support: Use your own CSS file
- π Emoji Support: Emojis display properly in PDF
- π Rich Markdown Support: Tables, code blocks, syntax highlighting
- π’ Page Numbering: Automatic page numbers
- π Table Support: Markdown tables look great
- π» Code Blocks: Code blocks with syntax highlighting
- π― Wildcard Support: Process multiple files at once
- π Progress Tracking: Process status and logs in GUI
- Install required packages:
pip install -r requirements.txtNote: WeasyPrint may require some system dependencies:
- macOS:
brew install cairo pango gdk-pixbuf libffi - Ubuntu/Debian:
sudo apt-get install python3-cffi python3-brotli libpango-1.0-0 libpangoft2-1.0-0 - Windows: Usually installs automatically
You can use the graphical interface for the easiest usage:
Open with a single command:
./md2pdfor
python md_to_pdf_gui.pyAdd to PATH for access from anywhere:
# For macOS/Linux, add to ~/.zshrc or ~/.bashrc file:
export PATH="$PATH:/Users/tahsinmert/Desktop/md_to_pdf"
# Then you can run from anywhere:
md2pdfGUI features:
- π File selection dialogs
- π¨ CSS file selection (optional)
- π Output PDF file specification
- π Progress bar
- π Process logs
- β Success/error messages
- π One-click conversion
python md_to_pdf.py file.mdThis command creates file.pdf.
python md_to_pdf.py file.md -o output.pdfpython md_to_pdf.py file.md -c custom.csspython md_to_pdf.py file1.md file2.md file3.mdor using wildcards:
python md_to_pdf.py *.mdYou can use the ornek.md file to test the program:
python md_to_pdf.py ornek.mdYou can fully customize your PDF's appearance by editing the custom.css file. An example CSS file is available in the project.
- Page size and margins
- Font families and sizes
- Colors and backgrounds
- Table styles
- Code block styles
- Header and footer areas
- β Headings (H1-H6)
- β Paragraphs
- β Bold and italic text
- β Code blocks and inline code
- β Syntax highlighting
- β Tables
- β Lists (ordered and unordered)
- β Blockquotes
- β Links
- β Images
- β Horizontal rules
- β Emojis π π β¨
If you're having trouble installing WeasyPrint:
macOS:
brew install cairo pango gdk-pixbuf libffi
pip install weasyprintUbuntu/Debian:
sudo apt-get install python3-cffi python3-brotli libpango-1.0-0 libpangoft2-1.0-0
pip install weasyprintFor emojis to display properly, emoji fonts must be installed on your system. They are usually installed on macOS and modern Linux distributions.
This project is free to use.
Feel free to open an issue for your suggestions and contributions!