Skip to main content

Generate a single PDF file from MkDocs repository

Project description

PDF Generate Plugin for MkDocs

This plugin will generate a PDF single PDF file from your MkDocs repository. This plugin is inspired by MkDocs PDF Export Plugin.

Features

  • Cover and Table of Contents integrated in the PDF
  • Automatically numbers on heading(h1-h3).
  • Shift down sub-page headings level.
  • using WeasyPrint.

Sample output

Requirements

  1. This package requires MkDocs version 1.0 or higher (0.17 works as well)
  2. Python 3.4 or higher
  3. WeasyPrint depends on cairo, Pango and GDK-PixBuf which need to be installed separately. Please follow the installation instructions for your platform carefully:

If you want to add a new theme, see adding support for new themes for more information.

How to use

Installation

  1. Install the package with pip:

    pip install git+https://github.com/orzih/mkdocs-with-pdf
    
  2. Enable the plugin in your mkdocs.yml:

    plugins:
        - with-pdf
    

    More information about plugins in the MkDocs documentation.

Testing

When building your repository with mkdocs build, you should now see the following message at the end of your build output:

Converting 10 articles to PDF took 7.1s

Configuration

You may customize the plugin by passing options in mkdocs.yml:

plugins:
    - with-pdf:
        #author: WHO
        #copyright: ANY TEXT
        #
        #cover: false
        #cover_title: TITLE TEXT
        #cover_subtitle: SUBTITLE TEXT
        #heading_shift: false
        #toc_level: 3
        #ordered_chapter_level: 2
        #excludes_children:
        #    - 'release-notes/:upgrading'
        #    - 'release-notes/:changelog'
        #
        #output_path: any-place/document.pdf
        #enabled_if_env: ENABLE_PDF_EXPORT
        #
        #debug_html: true
        #verbose: true

Options

for Properties
  • author

    Set the author text.
    default: use site_author in your project mkdocs.yml

  • copyright

    Set the author text.
    default: use copyright in your project mkdocs.yml

author and copyright values are drawn in Cover, and you can use '@page' content.

@page {
  @bottom-left {
    content: string(author);
  }
  @bottom-right {
    content: string(copyright);
  }
}
for Cover
  • cover

    Set the value to false if you don't need a cover page.
    default: true

  • cover_title

    Set the title text in cover page.
    default: use site_name in your project mkdocs.yml

  • cover_subtitle

    Set the subtitle text in cover page.
    default: None

for Heading and TOC
  • heading_shift

    Set this value to false, disable shift heading in child page.
    default: true

    In this flags enable, heading move down one level in child page.

  • toc_level

    Set the level of Table of Content. This value is enabled in the range of from 1 to 3.
    default: 3

  • ordered_chapter_level

    Set the level of heading number addition. This value is enabled in the range of from 1 to 3.
    default: 3

  • excludes_children

    Set the page id of nav url. If the id matches in this list, it will be excluded from the heading number addition and table of contents.
    default: []

... and more
  • output_path

    This option allows you to use a different destination for the PDF file.
    default: pdf/document.pdf

  • enabled_if_env

    Setting this option will enable the build only if there is an environment variable set to 1. This is useful to disable building the PDF files during development, since it can take a long time to export all files.
    default: None

  • debug_html

    Setting this to true will out HTML to stdout on build time.
    default: false

    You can try this:

    mkdocs build > for_pdf_print.html
    
  • verbose

    Setting this to true will show all WeasyPrint debug messages during the build.
    default: false

Contributing

From reporting a bug to submitting a pull request: every contribution is appreciated and welcome. Report bugs, ask questions and request features using Github issues. If you want to contribute to the code of this project, please read the Contribution Guidelines.

Special thanks to


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

mkdocs-with-pdf-0.1.0.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

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

mkdocs_with_pdf-0.1.0-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs-with-pdf-0.1.0.tar.gz.

File metadata

  • Download URL: mkdocs-with-pdf-0.1.0.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.9

File hashes

Hashes for mkdocs-with-pdf-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f32d7a63112b2bf1ef6303a4edeb4f8b146d3dbe0fb2edefa31f4ccd2447b7fb
MD5 c2234cc64d08b4f47149b48f20fc0c91
BLAKE2b-256 d4796dcb01eebe738fb4e820fc6499ba32a561487df803868e6f1c3d1b5de850

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mkdocs_with_pdf-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.9

File hashes

Hashes for mkdocs_with_pdf-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 71db0dff831a65c999ad1ecbec0b42f14d967e71be822fe6fb7d77773654cb48
MD5 4d3e7530fdca317d29a1c7f0bdc6461f
BLAKE2b-256 47a8ff6feb4e0e75d8484773b56e63ae6d89a4dcb02b2b8d9664a6dedf70b8ba

See more details on using hashes here.

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