markdown-pdf is a Python library designed to convert Markdown documents into PDF files. It utilizes `markdown-it-py` for efficient Markdown to HTML conversion and `PyMuPDF` for robust HTML to PDF rendering. Currently at version 1.13.1, the library is actively maintained with several releases per year, continuously adding new features and improvements.
pip install markdown-pdfVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a multi-section PDF from Markdown strings. It shows initializing `MarkdownPdf` with options like `toc_level` and `optimize`, adding individual `Section` objects with custom settings (like disabling TOC for a section or applying `user_css`), and finally setting document metadata before saving the PDF to a file.
Assess the impact of the AGPL-3.0 license on your project's usage, distribution, and overall licensing strategy.
Familiarize yourself with the AGPL-3.0 license to understand its implications for your software's distribution and source code availability.
Explicitly set the `root` parameter in `Section(markdown_content, root='path/to/image_assets')` to the base directory containing your image files.
To have content flow continuously on a single page, combine all desired Markdown content into a single `Section` object.
Consult the `markdown-pdf` documentation to understand how to enable and configure these plugins for diagram rendering.
Install the library using pip: `pip install markdown-pdf`
Ensure the image file exists and its path in the Markdown is correct relative to the 'root' directory specified when creating a `Section` (default is current working directory). For example: `pdf.add_section(Section(markdown_text, root='./path/to/images'))`.
Verify the Mermaid/PlantUML syntax is valid, ensure any external diagram rendering servers (if used by a plugin) are accessible and configured correctly, and confirm the relevant plugin is enabled and properly configured in your `MarkdownPdf` instance.
Ensure the custom font files are available in a directory accessible to the application (e.g., in the 'root' directory or a path specified in CSS's `@font-face` rule) and correctly referenced in the `user_css` provided to the `Section`.