Generate a single PDF file from MkDocs repository
Project description
PDF Generate Plugin for MkDocs
This plugin will generate a 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
- This package requires MkDocs version 1.0 or higher (0.17 works as well)
- Python 3.5 or higher
- 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
-
Install the package with pip:
pip install mkdocs-with-pdf
-
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
#
#toc_title: TOC TITLE TEXT
#heading_shift: false
#toc_level: 3
#ordered_chapter_level: 2
#excludes_children:
# - 'release-notes/:upgrading'
# - 'release-notes/:changelog'
#
#exclude_pages:
# - 'bugs/'
# - 'appendix/contribute/'
#convert_iframe:
# - src: IFRAME SRC
# img: POSTER IMAGE URL
# text: ALTERNATE TEXT
# - src: ...
#two_columns_level: 3
#
#render_js: true
#headless_chrome_path: headless-chromium
#
#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: usesite_author
in your projectmkdocs.yml
-
copyright
Set the author text.
default: usecopyright
in your projectmkdocs.yml
author
andcopyright
values are drawn in Cover, and you can use '@page' content.@page { @bottom-left { content: string(author) !important; } @bottom-right { content: string(copyright) !important; } }
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: usesite_name
in your projectmkdocs.yml
-
cover_subtitle
Set the subtitle text in cover page.
default:None
for Heading and TOC
-
toc_title
Set the title text of Table of Content.
default:Table of Content
since:v0.4.0
-
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
to3
.
default:3
-
ordered_chapter_level
Set the level of heading number addition. This value is enabled in the range of from
1
to3
.
default:3
-
excludes_children
Set the page
id
ofnav
url. If theid
matches in this list, it will be excluded from the heading number addition and table of contents.
default:[]
for Page
-
exclude_pages
Set the page
id
ofnav
url. If theid
matches in this list, it will be excluded page contents.
default:[]
since:v0.3.0
-
convert_iframe
List of
iframe
toa
conversions. Everyiframe
that matches asrc
in this list will be replace toa
contains eachimg
and/ortext
. it's using for such as embedded VIDEO.
default:[]
since:v0.6.0
-
two_columns_level
(Experimental)Set the heading level of Two Column Layout. Currently only
0
(disable) or3
is valid for this value. So slow processing, but a little nice.default:
0
since:v0.7.0
Renderer for JavaScript
-
render_js
Set the value to
true
if you're using 'MathJax', 'Twemoji' or any more.
Require "Chrome" which has "headless" mode.default:
false
since:v0.7.0
-
headless_chrome_path
Set the "Headless Chrome" program path.
Ifrender_js
isfalse
, this value will be ignored.default:
chromium-browser
Check on your system:
$ <PROGRAM_PATH> --headless \ --disable-gpu \ --dump-dom \ <ANY_SITE_URL(eg. 'https://google.com')>
... 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 tostdout
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
- Terry Zhao the author of the MkDocs PDF Export Plugin the source of our inspiration. We've used some of his code in this project.
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
Hashes for mkdocs_with_pdf-0.7.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3954328e18ad25c3ca4301b694aac8c2084e617464794bc4f08ccabde580ab4a |
|
MD5 | 5fbcbcfd439186f09eb067fd4e98529d |
|
BLAKE2b-256 | fd946dfee6a2948e717b3e26bfc937210dff606904fbede5e381a2b3170707df |