Skip to main content

Markdown to pdf renderer

Project description

markdown-pdf

This is a small Python class that links two libraries: markdown-it-py and PyMuPDF. This class will create a PDF file from your set of markdown files.

Installation

pip install markdown-pdf

Usage

from markdown_pdf import Section, MarkdownPdf

pdf = MarkdownPdf(toc_level=2)

pdf.add_section(Section("# Title\n", toc=False))
pdf.add_section(Section("# Head1\n\nbody\n"))
pdf.add_section(Section("## Head2\n\n### Head3\n\n"))

pdf.save(self.build("with_toc.pdf"))

Pdf

The Section class defines a portion of markdown data, which is processed according to the same rules. The next Section data starts on a new page.

The Section class can set the following attributes.

  • toc: whether to include the headers <h1> - <h6> of this section in the TOC. Default is True.
  • root: the name of the root directory from which the image file paths starts in markdown. Default ".".
  • paper_size: name of paper size, as described here. Default "A4".
  • borders: size of borders. Default (36, 36, -36, -36).

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

markdown_pdf-1.0.tar.gz (3.9 kB view hashes)

Uploaded Source

Built Distribution

markdown_pdf-1.0-py3-none-any.whl (4.0 kB view hashes)

Uploaded Python 3

Supported by

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