Skip to main content

Convert Markdown files to well-formatted PDF documents

Project description

Markdown to PDF Converter

A pip-installable Markdown to PDF converter with a command-line interface built on ReportLab and Matplotlib.

Features

  • Converts Markdown files to styled PDF documents
  • Supports headings, lists, block quotes, code blocks, tables, images, and math
  • CLI with required input and optional output
  • Configurable font family
  • Configurable color scheme
  • Configurable page size

Installation

Install from this project directory:

pip install .

After installation, the CLI command is available as:

md-to-pdf

CLI Usage

md-to-pdf INPUT [OUTPUT] [--font FONT] [--color-scheme {classic,mono,warm}] [--page-size {A4,LETTER,LEGAL}]

Argument Behavior

  1. INPUT is required.
  2. OUTPUT is optional. If omitted, output is created next to the input file with .pdf suffix.
  3. --font can be passed.
  4. --color-scheme can be passed.
  5. --page-size can be passed.

Examples

Convert with default output path:

md-to-pdf Docs/initial_proposal_v2.md

Convert with explicit output path:

md-to-pdf Docs/initial_proposal_v2.md Docs/initial_proposal_v2_custom.pdf

Convert with custom font:

md-to-pdf Docs/initial_proposal_v2.md --font "Times New Roman"

Convert with warm color scheme and LETTER page size:

md-to-pdf Docs/initial_proposal_v2.md --color-scheme warm --page-size LETTER

Python API Usage

from pathlib import Path
from md_to_pdf import markdown_to_pdf

markdown_to_pdf(
    Path("Docs/initial_proposal_v2.md"),
    Path("Docs/initial_proposal_v2.pdf"),
    font="serif",
    color_scheme="classic",
    page_size_name="A4",
)

Notes

  • Dependencies are installed automatically through pip: reportlab, matplotlib
  • Image paths in Markdown are resolved relative to the input Markdown file

Publish To PyPI With GitHub Actions (Trusted Publishing)

This repository includes a workflow at .github/workflows/publish-pypi.yml that publishes to PyPI using trusted publishing (OIDC), so no PyPI API token is needed in GitHub secrets.

One-time setup

  1. Push this repository to GitHub.
  2. In GitHub, create an environment named pypi for the repository.
  3. In PyPI, open your project settings and add a trusted publisher with:
    • Owner: your GitHub user/org
    • Repository: this repository name
    • Workflow: publish-pypi.yml
    • Environment: pypi

Release flow

  1. Bump version in pyproject.toml (for example from 0.1.0 to 0.1.1).
  2. Commit and push.
  3. Create a GitHub Release (or publish a release from a tag).
  4. The workflow builds and uploads package files to PyPI automatically.

Manual trigger

You can also run the same workflow manually from the Actions tab using workflow_dispatch.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

md_to_pdf_converter-0.1.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

md_to_pdf_converter-0.1.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file md_to_pdf_converter-0.1.0.tar.gz.

File metadata

  • Download URL: md_to_pdf_converter-0.1.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for md_to_pdf_converter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 eb3e03c55c1cbf8d279787931b9167c8c7c88ac67b3a7c859efcf76103c45a6d
MD5 6cc3758a72e842fa883dc3a71ce97cb7
BLAKE2b-256 daa861b828ca0246bc25bbdda09709b2526e82bed7929f3bfd9e3a8d414ae029

See more details on using hashes here.

Provenance

The following attestation bundles were made for md_to_pdf_converter-0.1.0.tar.gz:

Publisher: publish-pypi.yml on hoseinmrh/Markdown-to-PDF-Converter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file md_to_pdf_converter-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for md_to_pdf_converter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 59eaa28e1b459ca8ec7ffb7d5c3c8cf88ca05dea43e7e3daed102859fc3043e9
MD5 22da973bc72f5ee271cbadd2706fe8ea
BLAKE2b-256 0d6f496548ae943128f58ddf8d65477610241137269e6af0a3646b825c833a08

See more details on using hashes here.

Provenance

The following attestation bundles were made for md_to_pdf_converter-0.1.0-py3-none-any.whl:

Publisher: publish-pypi.yml on hoseinmrh/Markdown-to-PDF-Converter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page