Giter VIP home page Giter VIP logo

mkdocs-with-pdf's Introduction

PDF Generate Plugin for MkDocs

PyPI version

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.

Samples

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:

How to use

Installation

  1. Install the package with pip:

    pip install 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

mkdocs-with-pdf's People

Contributors

binnes avatar orzih avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.