### Install markdown-pdf Python Module Source: https://github.com/vb64/markdown-pdf/blob/main/README.md This command installs the `markdown-pdf` Python module using pip, making it available for use in your Python projects. ```bash pip install markdown-pdf ``` -------------------------------- ### Setup and Run Tests for markdown-pdf Development Source: https://github.com/vb64/markdown-pdf/blob/main/README.md These commands outline the steps for setting up the development environment and running tests for the `markdown-pdf` project. It involves cloning the repository, navigating into it, and using `make` commands for setup and testing. ```bash git clone git@github.com:vb64/markdown-pdf.git cd markdown-pdf make setup PYTHON_BIN=/path/to/python3 make tests ``` -------------------------------- ### Install markdown-pdf Python Module Source: https://github.com/vb64/markdown-pdf/blob/main/fixture/hrefs.md This command installs the `markdown-pdf` Python module using pip, making it available for use in your Python projects. ```Bash pip install markdown-pdf ``` -------------------------------- ### Add Section with External and Internal Hyperlinks Source: https://github.com/vb64/markdown-pdf/blob/main/README.md This example adds a section containing both external and internal hyperlinks. Each new section added with `add_section` will start on a new page in the generated PDF. ```python text = """# Section with links - [External link](https://github.com/vb64/markdown-pdf) - [Internal link to Head1](#head1) - [Internal link to Head3](#head3) """ pdf.add_section(Section(text)) ``` -------------------------------- ### Add Section with Markdown Table and Custom CSS Source: https://github.com/vb64/markdown-pdf/blob/main/README.md This example demonstrates adding a section that includes a Markdown-formatted table. Custom CSS is applied to define borders for the table, its headers, and cells, enhancing its visual presentation in the PDF. ```python text = """# Section with Table |TableHeader1|TableHeader2| |--|--| |Text1|Text2| |ListCell|| """ css = "table, th, td {border: 1px solid black;}" pdf.add_section(Section(text), user_css=css) ``` -------------------------------- ### Initialize MarkdownPdf with TOC and Optimization Source: https://github.com/vb64/markdown-pdf/blob/main/README.md This snippet demonstrates how to initialize the `MarkdownPdf` class, configuring it to generate a Table of Contents up to level 2 headings and optimize the resulting PDF file for size. ```python from markdown_pdf import MarkdownPdf pdf = MarkdownPdf(toc_level=2, optimize=True) ``` -------------------------------- ### Python Project Dependency List Source: https://github.com/vb64/markdown-pdf/blob/main/deploy.txt Lists the Python packages and their minimum versions required for project development and distribution. These dependencies are crucial for tasks such as building source distributions, wheels, and uploading packages to repositories. ```Python setuptools>=42 wheel build twine ``` -------------------------------- ### Save Generated PDF Document to File Source: https://github.com/vb64/markdown-pdf/blob/main/README.md This final step saves the constructed PDF document to a specified file path. The `save()` method writes all added sections and applied settings to the output PDF. ```python pdf.save("guide.pdf") ``` -------------------------------- ### MarkdownPdf.meta Document Properties API Documentation Source: https://github.com/vb64/markdown-pdf/blob/main/README.md Documentation for the `MarkdownPdf.meta` dictionary properties, which allow assignment of standard PDF document metadata. These properties include creation date, modification date, creator, producer, title, author, subject, and keywords. ```APIDOC MarkdownPdf.meta Properties: creationDate: datetime (Default: current date) Description: The date and time when the document was created. modDate: datetime (Default: current date) Description: The date and time when the document was last modified. creator: string (Default: "PyMuPDF library: https://pypi.org/project/PyMuPDF") Description: The application that created the original document. producer: string (Default: "") Description: The application that produced the PDF document. title: string (Default: "") Description: The title of the document. author: string (Default: "") Description: The author of the document. subject: string (Default: "") Description: The subject of the document. keywords: string (Default: "") Description: Keywords associated with the document. ``` -------------------------------- ### Section Class Attributes API Documentation Source: https://github.com/vb64/markdown-pdf/blob/main/README.md Documentation for the `Section` class attributes, which define how a portion of markdown data is processed. Each attribute controls specific aspects like TOC inclusion, root directory for images, paper size, and border dimensions. ```APIDOC Section Class Attributes: toc: boolean (Default: True) Description: Whether to include the headers (h1-h6) of this section in the Table of Contents. root: string (Default: ".") Description: The name of the root directory from which image file paths start in markdown. paper_size: string (Default: "A4") Description: Name of paper size, as described in PyMuPDF documentation. borders: tuple (Default: (36, 36, -36, -36)) Description: Size of borders (left, top, right, bottom). ``` -------------------------------- ### Add Section with Multiple Heading Levels and Landscape Orientation Source: https://github.com/vb64/markdown-pdf/blob/main/README.md This code adds a section containing two different heading levels, both of which will be included in the PDF's Table of Contents. The `paper_size="A4-L"` parameter sets the page orientation for this section to landscape. ```python pdf.add_section(Section("## Head2\n\n### Head3\n\n", paper_size="A4-L")) ``` -------------------------------- ### Set Metadata Properties for PDF Document Source: https://github.com/vb64/markdown-pdf/blob/main/README.md This snippet shows how to set various metadata properties for the generated PDF document, such as the title and author. These properties are stored in the `pdf.meta` dictionary. ```python pdf.meta["title"] = "User Guide" pdf.meta["author"] = "Vitaly Bogomolov" ``` -------------------------------- ### Add Section with Centered Title, Embedded Image, and TOC Entry Source: https://github.com/vb64/markdown-pdf/blob/main/README.md This snippet adds a section where the heading is centered using custom CSS. It also embeds an image from a local path and ensures the heading is included in the PDF's Table of Contents. ```python pdf.add_section( Section("# Head1\n\n![python](img/python.png)\n\nbody\n"), user_css="h1 {text-align:center;}" ) ``` -------------------------------- ### Add Section to PDF Without Table of Contents Entry Source: https://github.com/vb64/markdown-pdf/blob/main/README.md This code adds a new section to the PDF document. The `toc=False` parameter ensures that the title of this section is not included in the generated Table of Contents. ```python from markdown_pdf import Section pdf.add_section(Section("# Title\n", toc=False)) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.