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
-
authorSet the author text.
default: usesite_authorin your projectmkdocs.yml -
copyrightSet the author text.
default: usecopyrightin your projectmkdocs.yml
authorandcopyrightvalues 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
-
coverSet the value to
falseif you don't need a cover page.
default:true -
cover_titleSet the title text in cover page.
default: usesite_namein your projectmkdocs.yml -
cover_subtitleSet the subtitle text in cover page.
default:None
for Heading and TOC
-
toc_titleSet the title text of Table of Content.
default:Table of Content
since:v0.4.0 -
heading_shiftSet this value to
false, disable shift heading in child page.
default:trueIn this flags enable, heading move down one level in child page.
-
toc_levelSet the level of Table of Content. This value is enabled in the range of from
1to3.
default:3 -
ordered_chapter_levelSet the level of heading number addition. This value is enabled in the range of from
1to3.
default:3 -
excludes_childrenSet the page
idofnavurl. If theidmatches in this list, it will be excluded from the heading number addition and table of contents.
default:[]
for Page
-
exclude_pagesSet the page
idofnavurl. If theidmatches in this list, it will be excluded page contents.
default:[]
since:v0.3.0 -
convert_iframeList of
iframetoaconversions. Everyiframethat matches asrcin this list will be replace toacontains eachimgand/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) or3is valid for this value. So slow processing, but a little nice.default:
0
since:v0.7.0
Renderer for JavaScript
-
render_jsSet the value to
trueif you're using 'MathJax', 'Twemoji' or any more.
Require "Chrome" which has "headless" mode.default:
false
since:v0.7.0 -
headless_chrome_pathSet the "Headless Chrome" program path.
Ifrender_jsisfalse, 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_pathThis option allows you to use a different destination for the PDF file.
default:pdf/document.pdf -
enabled_if_envSetting 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_htmlSetting this to
truewill out HTML tostdouton build time.
default:falseYou can try this:
mkdocs build > for_pdf_print.html
-
verboseSetting this to
truewill 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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mkdocs-with-pdf-0.7.2.tar.gz.
File metadata
- Download URL: mkdocs-with-pdf-0.7.2.tar.gz
- Upload date:
- Size: 24.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd0c0251a73a2c85751f2c98b1ae76bde504ff9f730d7d30a97dc24d9a55be56
|
|
| MD5 |
a725ac77ef645c045d82e1d045374da9
|
|
| BLAKE2b-256 |
3d276fd93eb9324104ef00fbf6a9bfef49f49551e0d00c13a5a15fd8bcc7773a
|
File details
Details for the file mkdocs_with_pdf-0.7.2-py3-none-any.whl.
File metadata
- Download URL: mkdocs_with_pdf-0.7.2-py3-none-any.whl
- Upload date:
- Size: 31.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b8e5f671dd5af9204332fd8ecd23bae2612091a909886c66db93acd8742bd0b
|
|
| MD5 |
04ad1cb213f53816ebad6232474d1cd7
|
|
| BLAKE2b-256 |
149936659963e02d280701e449de45fb8733fc23d913136bb694692a89b5127c
|