Markdown2PDF Β
This Python script converts Markdown (.md) files into PDF documents and was originally developed to help convert ChatGPT's Deep Research to PDF. Due to changes by OpenAI, this functionality is now natively supported, but they also removed the hyperlinks for the sources when copying the content. Therefore, this project is discontinued. For testing purposes, a demo Markdown file from before these changes were introduced is included in this repository. However, the script remains fully functional as a general Markdown-to-PDF converter. It can be used via the command line to convert individual Markdown files or in batches. Additionally, an app version quickly converts clipboard content to a PDF.

[!NOTE]
Images are written as ([image]()) in the Markdown and thus cannot directly be included in the PDF. An empty space is added instead, allowing images to be pasted in effortlessly using a PDF editor.
π Prerequisites (Command-line version)
Before running the script, ensure these are installed:
- Python β₯ 3.9
- Pandoc
- macOS:
brew install pandoc
- Linux:
sudo apt install pandoc
- Windows:
choco install pandoc
- XeLaTeX (part of any full LaTeX distribution)
- macOS:
brew install --cask mactex-no-gui
- Linux:
sudo apt install texlive-xetex
- Windows: Download MiKTeX
π How to run Markdown2PDF (Command-line version)
π Batch Conversion (multiple files)
Navigate in the terminal to the folder containing the .md files, then run: python3 /path/to/Markdown2PDF.py *.md. The PDFs will be created in the same folder as the Markdown files.
π Single-file Conversion
To convert a single Markdown file into a PDF with a custom filename, run: python3 /path/to/Markdown2PDF.py /path/to/file.md -o output.pdf. Replace file.md and output.pdf with the actual filenames.
[!TIP]
Running python3 /path/to/Markdown2PDF.py with zero arguments uses the clipboard for input, and the 'Save As . . .' dialog appears to save the PDF.
π How to Use the App Version (Clipboard-to-PDF)
An app version is also available for macOS, Windows, and Linux:
- Download the app for the required operating system from the GitHub Releases page.
- Copy the Markdown text to the clipboard.
- Double-click the app file, and the 'Save As . . .' dialog appears.
- Choose a save location, adjust a file name if needed, and confirm.
No command line or setup required!
[!IMPORTANT]
When launching Markdown2PDF for the first time on macOS, Gatekeeper will block it until approved:
- Open System Settings β Privacy & Security and scroll to the Security section at the bottom.
- Then under "Markdown2PDF.app was blocked to protect your Mac", click Open Anyway.
- In the next 'Open "Markdown2PDF.app"?' dialog window, click Open and authenticate if prompted.
π Changelog
- 17: initial public release
βοΈ License
The code of this project in Markdown2PDF.py and compiled binaries are licensed under the GNU Affero General Public License v3.0 (AGPL-3.0). See the LICENSE file for details. The README.md, all images, and example files in the examples/ folder are Copyright Β© 2025 Tim Macy. All rights reserved.
β οΈ Disclaimer
Markdown2PDF is an independent, private project. It's not affiliated with, endorsed by, sponsored by, or officially connected to OpenAI. All trademarks are property of their respective owners.