Skip to content

πŸš€ A modern Markdown to PDF converter with GUI & CLI support, custom CSS styling, emoji rendering, and syntax highlighting. Built with Python, WeasyPrint & Tkinter.

License

Notifications You must be signed in to change notification settings

tahsinmert/markdown-pdf-converter

Markdown to PDF Converter πŸ“„

A Python program that converts Markdown files to professional PDFs. Includes custom CSS support and emoji support.

Features ✨

  • πŸ–₯️ 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

Installation πŸš€

  1. Install required packages:
pip install -r requirements.txt

Note: 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

Usage πŸ“–

Graphical Interface (GUI) πŸ–₯️

You can use the graphical interface for the easiest usage:

Open with a single command:

./md2pdf

or

python md_to_pdf_gui.py

Add 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:
md2pdf

GUI features:

  • πŸ“ File selection dialogs
  • 🎨 CSS file selection (optional)
  • πŸ“„ Output PDF file specification
  • πŸ“Š Progress bar
  • πŸ“ Process logs
  • βœ… Success/error messages
  • πŸš€ One-click conversion

Command Line Usage πŸ’»

Basic Usage

python md_to_pdf.py file.md

This command creates file.pdf.

Specify Output File

python md_to_pdf.py file.md -o output.pdf

Using Custom CSS

python md_to_pdf.py file.md -c custom.css

Processing Multiple Files

python md_to_pdf.py file1.md file2.md file3.md

or using wildcards:

python md_to_pdf.py *.md

Example Markdown File

You can use the ornek.md file to test the program:

python md_to_pdf.py ornek.md

Custom CSS Customization 🎨

You can fully customize your PDF's appearance by editing the custom.css file. An example CSS file is available in the project.

CSS Features

  • Page size and margins
  • Font families and sizes
  • Colors and backgrounds
  • Table styles
  • Code block styles
  • Header and footer areas

Supported Markdown Features

  • βœ… 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 😊 πŸŽ‰ ✨

Troubleshooting πŸ”§

WeasyPrint Installation Issues

If you're having trouble installing WeasyPrint:

macOS:

brew install cairo pango gdk-pixbuf libffi
pip install weasyprint

Ubuntu/Debian:

sudo apt-get install python3-cffi python3-brotli libpango-1.0-0 libpangoft2-1.0-0
pip install weasyprint

Emojis Not Displaying

For emojis to display properly, emoji fonts must be installed on your system. They are usually installed on macOS and modern Linux distributions.

License πŸ“œ

This project is free to use.

Contributing 🀝

Feel free to open an issue for your suggestions and contributions!

About

πŸš€ A modern Markdown to PDF converter with GUI & CLI support, custom CSS styling, emoji rendering, and syntax highlighting. Built with Python, WeasyPrint & Tkinter.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published