Skip to main content

Allows the generation of the PDF version of your MkDocs documentation.

Project description

MkPDFs for MkDocs Build Status

:bangbang: This is a fork of original comwes/mkpdfs-mkdocs-plugin

:exclamation: There could be many things that are not up-to-date, but at this moment (20.09.2023) this plugin should work.

It's a MkDocs plugin that export your documentation in a single PDF file

MkPDFs for MkDocs

The MkPDFs plugin will export yor documentation in your MkDocs repository as a PDF file using WeasyPrint.

Unlike other plugin where customizing the design of the generated PDF is complicated, this plugin brings the ability to completely control the design of the generated PDF.

What makes this plugin particular, is that:

  1. Your documentation is exported as a single PDF file
  2. The order of pages fits the navigation as defined in the MkDocs configuration file
  3. The ability to override the default design to make it fit your needs
  4. The ability to exclude some files from the generated PDF
  5. No layout issues
  6. No conflict with the theme design
  7. Table of contents integrated in the PDF

Requirements

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

Limitation

The PDF version of the documentation will not be created if the used generated page content's is not enclosed in an <article> tag or in a <div> tag with property role="main".

Installation

Install the package with pip:

pip3 install mkpdfs-mkdocs

Enable the plugin in your mkdocs.yml as folowing

plugins:
    - search
    - mkpdfs

or with options

plugins:
    - search
    - mkpdfs:
        - company: The War Company Inc.
        - author: Monsieur Silvestre

Note: If you enable this plugin and you don't have plugins entry in your MkDocs config file yet, you will need to explicitly enable the search plugin. This plugin is enabled by default when no plugins entry is set.

You can find further information about plugins in the MkDocs documentation.

How does it work?

When building or serving your documentation with mkdocs build or mkdocs serve, the following message will be displayed if everything wend smoothly:

The PDF version of the documentation has been generated.

Options

This plugin supports following options to allow you better handle the customisation of the generated PDF.

Option Description
author The author of the document. This information will be printed on the cover page of the generated PDF.
company If this documentation is from a company, then you should provide this information. It will be displayed on the front page of the documentation, bellow the author information
toc_title The table of content title. The default value is Table of Contents
toc_position The position of the table of contents. This option supports 3 differents values: pre to put the toc at the beginning of the file but after the cover (the default value), post to put it at the end of the file or none to not generate it at all.
output_path The file name of the generated PDF, relative to the site_dir. By default this location is set to pdf/combined.pdf
pdf_links Create link to download the generated PDF to the top of each HTML page. By default this is enabled
design Relative to your MkDocs repository, this option is the location of the CSS file defining the layout of the generated PDF. If this option is not defined the default design will be used. Defining an non existing file will cause the build or serve failure.

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.

Thanks to

The idea of this plugin has raised while working on a project in the public sector. After many research I found some plugins that guided me to the current solution. They have inspired me a lot, so many 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

mkpdfs2-mkdocs-1.0.1.tar.gz (1.8 MB view details)

Uploaded Source

Built Distribution

mkpdfs2_mkdocs-1.0.1-py3-none-any.whl (1.8 MB view details)

Uploaded Python 3

File details

Details for the file mkpdfs2-mkdocs-1.0.1.tar.gz.

File metadata

  • Download URL: mkpdfs2-mkdocs-1.0.1.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for mkpdfs2-mkdocs-1.0.1.tar.gz
Algorithm Hash digest
SHA256 bc67ecdfa8efc4ed03efc88bc4163b546cf764db8732e0d0be0ab77cb0c89ecf
MD5 c4d0de9017597a7f9f431e9f8dc61438
BLAKE2b-256 373ab027731c9e614f05ec4a27130da3b89da324cf03e82c1ab7a248d0371d7b

See more details on using hashes here.

File details

Details for the file mkpdfs2_mkdocs-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mkpdfs2_mkdocs-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e2ccb58d426d6916e0236228bea02102fb8e5d553d5d6df4d92538be8474567d
MD5 baa96a8a4d11c27b50d7c23c0be921d3
BLAKE2b-256 b0e7534b514012e76eb1683301a505d46ba4bb547d69294ccfb4a064caff857f

See more details on using hashes here.

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