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
Create a pdf with TOC (bookmarks) from headings up to level 2.
from markdown_pdf import MarkdownPdf
pdf = MarkdownPdf(toc_level=2)
Add three sections of markdown to the pdf. Each section starts on a new page. Headings from the first section are not included in the TOC. The second section header is centered using CSS.
from markdown_pdf import Section
pdf.add_section(Section("# Title\n", toc=False))
pdf.add_section(Section("# Head1\n\nbody\n"), user_css="h1 {text-align:center;}")
pdf.add_section(Section("## Head2\n\n### Head3\n\n"))
Set the properties of the pdf document.
pdf.meta["title"] = "User Guide"
pdf.meta["author"] = "Vitaly Bogomolov"
Save to file.
pdf.save("guide.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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file markdown_pdf-1.1.tar.gz.
File metadata
- Download URL: markdown_pdf-1.1.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5c72b1623e86efeaf1e8aee7190e18e5d5dcea5ad90c82664ad6c16a015bdbe
|
|
| MD5 |
3a5f552d9172ee1c37d788777c5959a6
|
|
| BLAKE2b-256 |
99406db7fc3927321253fc1150424b74c73f235015e67c379ca57832e81bc585
|
File details
Details for the file markdown_pdf-1.1-py3-none-any.whl.
File metadata
- Download URL: markdown_pdf-1.1-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de23f6b529b2ebe7bab5625a6f294e437b2998f1ab2d70383e828be19c0d9ec0
|
|
| MD5 |
9ff4f37bf17ce2df0fafadf2ed31ede3
|
|
| BLAKE2b-256 |
6352b8a45e64fbad7a8196fbb1817f2126d819b7f8ecb29fbb7d2f37e29e5678
|