mkdocs-with-pdf-multiply-docs


Namemkdocs-with-pdf-multiply-docs JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/orzih/mkdocs-with-pdf
SummaryGenerate a single PDF file from MkDocs repository
upload_time2023-08-29 09:44:24
maintainer
docs_urlNone
authororzih
requires_python>=3.6
licenseMIT
keywords mkdocs pdf weasyprint
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PDF Generate Plugin for MkDocs

[![PyPI version](https://img.shields.io/pypi/v/mkdocs-with-pdf.svg)](https://pypi.org/project/mkdocs-with-pdf)
[![PyPI downloads](https://img.shields.io/pypi/dm/mkdocs-with-pdf.svg)](https://pypi.org/project/mkdocs-with-pdf)

---

This plugin will generate a single PDF file from your MkDocs repository.
This plugin is inspired by [MkDocs PDF Export Plugin][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][weasyprint].

## Samples

* [PDF of _'MkDocs' docs_][sample_mkdocs]
* [PDF of _'Material for MkDocs' docs_][sample_mkdocs-material]

[sample_mkdocs]: https://github.com/orzih/mkdocs-with-pdf/blob/master/samples/mkdocs/README.md
[sample_mkdocs-material]: https://github.com/orzih/mkdocs-with-pdf/blob/master/samples/mkdocs-material/README.md

## Requirements

1. This package requires MkDocs version 1.0 or higher (0.17 works as well)
1. Python 3.6 or higher
1. WeasyPrint depends on cairo, Pango and GDK-PixBuf which need to be installed separately. Please follow the installation instructions for your platform carefully:
    * [Linux][weasyprint-linux]
    * [MacOS][weasyprint-macos]
    * [Windows][weasyprint-windows]

## How to use

### Installation

1. Install the package with pip:

    ```bash
    pip install mkdocs-with-pdf
    ```

2. Enable the plugin in your `mkdocs.yml`:

    ```yaml
    plugins:
        - with-pdf
    ```

    More information about plugins in the [MkDocs documentation][mkdocs-plugins].

#### 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`:

```yaml
plugins:
    - with-pdf:
        #author: WHO
        #copyright: ANY TEXT
        #
        #cover: false
        #back_cover: true
        #cover_title: TITLE TEXT
        #cover_subtitle: SUBTITLE TEXT
        #custom_template_path: TEMPLATES PATH
        #
        #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
        #show_anchors: 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.  
>
> ```css "e.g."
> @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`

* `back_cover`

    Set the value to `true` if you need a back cover page.  
    **default**: `false`  
    _**since**: `v0.8.0`_

    You would be better to install the `qrcode` package:

    ```sh
    pip install qrcode
    ```

* `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`

* `cover_logo`

    Set the logo image in cover page. This value is URL or simply specify the relative path to the docs directory.  
    **default**: `None`  
    _**since**: `v0.8.0`_

##### 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` 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**: `[]`

##### for Page

* `exclude_pages`

    Set the page `id` of `nav` url. If the `id` matches in this list, it will be excluded page contents.  
    **default**: `[]`  
    _**since**: `v0.3.0`_

* `convert_iframe`

    List of `iframe` to `a` conversions. Every `iframe` that matches a `src` in this list will be replace to `a` contains each `img` and/or `text`. it's using for such as embedded VIDEO.  
    **default**: `[]`  
    _**since**: `v0.6.0`_

    @see [Sample of _MkDocs Material_](https://github.com/orzih/mkdocs-with-pdf/blob/master/samples/mkdocs-material/)

* `two_columns_level` (Experimental)

    Set the heading level of **_Two Column Layout_**. Currently only `0`(disable) or `3` is valid for this value. So slow processing, but a little nice.  

    **default**: `0`  
    _**since**: `v0.7.0`_

    @see [Sample of _MkDocs Material_](https://github.com/orzih/mkdocs-with-pdf/blob/master/samples/mkdocs-material/)

##### Renderer for JavaScript

* `render_js`

    Set the value to `true` if you're using '[MathJax](https://www.mathjax.org/)', '[Twemoji](https://twemoji.twitter.com/)' or any more.  
    Require "Chrome" which has "headless" mode.  

    **default**: `false`  
    _**since**: `v0.7.0`_

* `headless_chrome_path`

    Set the "Headless Chrome" program path.  
    If `render_js` is _`false`_, 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`

* `custom_template_path`

    The path where your custom `cover.html` and/or `styles.scss` are located.
    **default**: `templates`  
    _**since**: `v0.8.0`_

* `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`

    PDF generation can take significantly longer than HTML generation which can slow down mkdocs's built-in dev-server.

    Adding `enabled_if_env: ENABLE_PDF_EXPORT` under `- with-pdf:` disables PDF generation during development.  Run the dev-server normally:

    ```sh
    $ mkdocs serve
    INFO    -  Browser Connected: http://127.0.0.1:8000/
    INFO    -  Running task: builder (delay: None)
    INFO    -  Building documentation...
    WARNING -  without generate PDF(set environment variable ENABLE_PDF_EXPORT to 1 to enable)
    ... 2 seconds later ...
    INFO    -  Reload 1 waiters: /.../index.md
    ```

    and to build files to deploy specify `ENABLE_PDF_EXPORT=1` at the command line:

    ```sh
    $ ENABLE_PDF_EXPORT=1 mkdocs build
    ...
    INFO    -  Converting 10 articles to PDF took 7.1s
    INFO    -  Documentation built in 8.29 seconds
    ```

* `debug_html`

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

    You can try this:

    ```bash
    mkdocs build > for_pdf_print.html
    ```

    ...and browse output with Google Chrome. [Chrome DevTools Into Print Preview Mode](https://developers.google.com/web/tools/chrome-devtools/css/print-preview) will you help.

    Note: WeasyPrint and Google Chrome are not fully compatible.

* `show_anchors`

    Setting this to `true` will list out of anchor points provided during the build as info message.  
    **default**: `false`  
    _**since**: `v0.7.4`_

* `verbose`

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

## Custom cover page and document style

It is possible to create a custom cover page for the document.
You can also add a custom style sheet to modify the whole document.

To do so, add a `templates` folder at the root level of your `mkdocs` project and place a `cover.html` and/or a `styles.scss` inside.
Alternatively, you can specify a different location with the `custom_template_path` option.

### Custom cover page

Using [jinja2](https://jinja.palletsprojects.com/en/2.11.x/templates/) syntax, you can access all data from your `mkdocs.yml`.
To make template creation easier, you can use `plugin_some_plugin` to access variables from plugins.
E.g. use `{{ author }}` to get the author from your `mkdocs.yml` that looks like:

```yaml
plugins:
    - with-pdf:
        author: WHO
```

You can use custom variables [`extra:` in your `mkdocs.yml`](https://www.mkdocs.org/user-guide/configuration/#extra)
And, you can check it in the log if run with `verbose` or `debug_html` options.

### Custom stylesheet

Since your stylesheet is appended to the default ones, you can override every setting from them.

Tip: setting the `debug_html` option to `true` to get the generated html that is passed to `weasyprint` can help you determine the html tags, classes or identifiers you want to modify in your stylesheet.

### Advanced Rendering Hooks (Experimental)

You can hook the PDF rendering process by creating a `pdf_event_hook.py`(or `pdf_event_hook/__init__.py`) in your working directory _(usually the same directory as` mkdocs.yml`)_.  
_**since**: `v0.8.2`_

#### Sample `pdf_event_hook.py` (or `pdf_event_hook/__init__.py`)

```python
import logging

from bs4 import BeautifulSoup
from mkdocs.structure.pages import Page


def inject_link(html: str, href: str,
                page: Page, logger: logging) -> str:
    """Adding PDF View button on navigation bar(using material theme)"""

    def _pdf_icon():
        _ICON = '''
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<path d="M128,0c-17.6,0-32,14.4-32,32v448c0,17.6,14.4,32,32,32h320c17.6,0,32-14.4,32-32V128L352,0H128z" fill="#E2E5E7"/>
<path d="m384 128h96l-128-128v96c0 17.6 14.4 32 32 32z" fill="#B0B7BD"/>
<polygon points="480 224 384 128 480 128" fill="#CAD1D8"/>
<path d="M416,416c0,8.8-7.2,16-16,16H48c-8.8,0-16-7.2-16-16V256c0-8.8,7.2-16,16-16h352c8.8,0,16,7.2,16,16  V416z" fill="#F15642"/>
<g fill="#fff">
<path d="m101.74 303.15c0-4.224 3.328-8.832 8.688-8.832h29.552c16.64 0 31.616 11.136 31.616 32.48 0 20.224-14.976 31.488-31.616 31.488h-21.36v16.896c0 5.632-3.584 8.816-8.192 8.816-4.224 0-8.688-3.184-8.688-8.816v-72.032zm16.88 7.28v31.872h21.36c8.576 0 15.36-7.568 15.36-15.504 0-8.944-6.784-16.368-15.36-16.368h-21.36z"/>
<path d="m196.66 384c-4.224 0-8.832-2.304-8.832-7.92v-72.672c0-4.592 4.608-7.936 8.832-7.936h29.296c58.464 0 57.184 88.528 1.152 88.528h-30.448zm8.064-72.912v57.312h21.232c34.544 0 36.08-57.312 0-57.312h-21.232z"/>
<path d="m303.87 312.11v20.336h32.624c4.608 0 9.216 4.608 9.216 9.072 0 4.224-4.608 7.68-9.216 7.68h-32.624v26.864c0 4.48-3.184 7.92-7.664 7.92-5.632 0-9.072-3.44-9.072-7.92v-72.672c0-4.592 3.456-7.936 9.072-7.936h44.912c5.632 0 8.96 3.344 8.96 7.936 0 4.096-3.328 8.704-8.96 8.704h-37.248v0.016z"/>
</g>
<path d="m400 432h-304v16h304c8.8 0 16-7.2 16-16v-16c0 8.8-7.2 16-16 16z" fill="#CAD1D8"/>
</svg>
'''  # noqa: E501
        return BeautifulSoup(_ICON, 'html.parser')

    logger.info(f'(hook on inject_link: {page.title})')
    soup = BeautifulSoup(html, 'html.parser')

    nav = soup.find(class_='md-header-nav')
    if not nav:
        # after 7.x
        nav = soup.find('nav', class_='md-header__inner')
    if nav:
        a = soup.new_tag('a', href=href, title='PDF',
                         **{'class': 'md-header__button md-header-nav__button md-icon'})
        a.append(_pdf_icon())
        nav.append(a)
        return str(soup)

    return html


# def pre_js_render(soup: BeautifulSoup, logger: logging) -> BeautifulSoup:
#     logger.info('(hook on pre_js_render)')
#     return soup


# def pre_pdf_render(soup: BeautifulSoup, logger: logging) -> BeautifulSoup:
#     logger.info('(hook on pre_pdf_render)')
#     tag = soup.find(lambda tag: tag.name ==
#                     'body' and 'data-md-color-scheme' in tag.attrs)
#     if tag:
#         tag['data-md-color-scheme'] = 'print'
#     return soup
```

... and check log:

```sh
$ mkdocs build
INFO    -  Found PDF rendering event hook module.
INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /tmp/sample/site
INFO    -  (hook on inject_link: Home)
   ...
```

## 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][github-issues].
If you want to contribute to the code of this project, please read the [Contribution Guidelines][contributing].

## Special thanks to

* [Terry Zhao][zhaoterryy] the author of the [MkDocs PDF Export Plugin][mkdocs-pdf-export-plugin] the source of our inspiration. We've used some of his code in this project.

[mkdocs-pdf-export-plugin]: https://github.com/zhaoterryy/mkdocs-pdf-export-plugin
[zhaoterryy]:  https://github.com/zhaoterryy

[weasyprint]: http://weasyprint.org/
[weasyprint-linux]: https://weasyprint.readthedocs.io/en/latest/install.html#linux
[weasyprint-macos]: https://weasyprint.readthedocs.io/en/latest/install.html#os-x
[weasyprint-windows]: https://weasyprint.readthedocs.io/en/latest/install.html#windows

[mkdocs-plugins]: http://www.mkdocs.org/user-guide/plugins/
[mkdocs-material]: https://github.com/squidfunk/mkdocs-material

[contributing]: https://github.com/orzih/mkdocs-with-pdf/blob/master/CONTRIBUTING.md
[github-issues]: https://github.com/orzih/mkdocs-with-pdf/issues



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/orzih/mkdocs-with-pdf",
    "name": "mkdocs-with-pdf-multiply-docs",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "mkdocs pdf weasyprint",
    "author": "orzih",
    "author_email": "orzih@mail.com",
    "download_url": "https://files.pythonhosted.org/packages/9c/79/25af785d976b6672f169e6768d602bf688597c307401fb77e80d963519cd/mkdocs-with-pdf-multiply-docs-0.0.2.tar.gz",
    "platform": null,
    "description": "# PDF Generate Plugin for MkDocs\r\n\r\n[![PyPI version](https://img.shields.io/pypi/v/mkdocs-with-pdf.svg)](https://pypi.org/project/mkdocs-with-pdf)\r\n[![PyPI downloads](https://img.shields.io/pypi/dm/mkdocs-with-pdf.svg)](https://pypi.org/project/mkdocs-with-pdf)\r\n\r\n---\r\n\r\nThis plugin will generate a single PDF file from your MkDocs repository.\r\nThis plugin is inspired by [MkDocs PDF Export Plugin][mkdocs-pdf-export-plugin].\r\n\r\n## Features\r\n\r\n* Cover and Table of Contents integrated in the PDF\r\n* Automatically numbers on heading(h1-h3).\r\n* Shift down sub-page headings level.\r\n* using [WeasyPrint][weasyprint].\r\n\r\n## Samples\r\n\r\n* [PDF of _'MkDocs' docs_][sample_mkdocs]\r\n* [PDF of _'Material for MkDocs' docs_][sample_mkdocs-material]\r\n\r\n[sample_mkdocs]: https://github.com/orzih/mkdocs-with-pdf/blob/master/samples/mkdocs/README.md\r\n[sample_mkdocs-material]: https://github.com/orzih/mkdocs-with-pdf/blob/master/samples/mkdocs-material/README.md\r\n\r\n## Requirements\r\n\r\n1. This package requires MkDocs version 1.0 or higher (0.17 works as well)\r\n1. Python 3.6 or higher\r\n1. WeasyPrint depends on cairo, Pango and GDK-PixBuf which need to be installed separately. Please follow the installation instructions for your platform carefully:\r\n    * [Linux][weasyprint-linux]\r\n    * [MacOS][weasyprint-macos]\r\n    * [Windows][weasyprint-windows]\r\n\r\n## How to use\r\n\r\n### Installation\r\n\r\n1. Install the package with pip:\r\n\r\n    ```bash\r\n    pip install mkdocs-with-pdf\r\n    ```\r\n\r\n2. Enable the plugin in your `mkdocs.yml`:\r\n\r\n    ```yaml\r\n    plugins:\r\n        - with-pdf\r\n    ```\r\n\r\n    More information about plugins in the [MkDocs documentation][mkdocs-plugins].\r\n\r\n#### Testing\r\n\r\nWhen building your repository with `mkdocs build`, you should now see the following message at the end of your build output:\r\n\r\n> Converting 10 articles to PDF took 7.1s\r\n\r\n### Configuration\r\n\r\nYou may customize the plugin by passing options in `mkdocs.yml`:\r\n\r\n```yaml\r\nplugins:\r\n    - with-pdf:\r\n        #author: WHO\r\n        #copyright: ANY TEXT\r\n        #\r\n        #cover: false\r\n        #back_cover: true\r\n        #cover_title: TITLE TEXT\r\n        #cover_subtitle: SUBTITLE TEXT\r\n        #custom_template_path: TEMPLATES PATH\r\n        #\r\n        #toc_title: TOC TITLE TEXT\r\n        #heading_shift: false\r\n        #toc_level: 3\r\n        #ordered_chapter_level: 2\r\n        #excludes_children:\r\n        #    - 'release-notes/:upgrading'\r\n        #    - 'release-notes/:changelog'\r\n        #\r\n        #exclude_pages:\r\n        #    - 'bugs/'\r\n        #    - 'appendix/contribute/'\r\n        #convert_iframe:\r\n        #    - src: IFRAME SRC\r\n        #      img: POSTER IMAGE URL\r\n        #      text: ALTERNATE TEXT\r\n        #    - src: ...\r\n        #two_columns_level: 3\r\n        #\r\n        #render_js: true\r\n        #headless_chrome_path: headless-chromium\r\n        #\r\n        #output_path: any-place/document.pdf\r\n        #enabled_if_env: ENABLE_PDF_EXPORT\r\n        #\r\n        #debug_html: true\r\n        #show_anchors: true\r\n        #verbose: true\r\n```\r\n\r\n#### Options\r\n\r\n##### for Properties\r\n\r\n* `author`\r\n\r\n    Set the author text.  \r\n    **default**: use `site_author` in your project `mkdocs.yml`\r\n\r\n* `copyright`\r\n\r\n    Set the author text.  \r\n    **default**: use `copyright` in your project `mkdocs.yml`\r\n\r\n> `author` and `copyright` values are drawn in Cover, and you can use '@page' content.  \r\n>\r\n> ```css \"e.g.\"\r\n> @page {\r\n>   @bottom-left {\r\n>     content: string(author) !important;\r\n>   }\r\n>   @bottom-right {\r\n>     content: string(copyright) !important;\r\n>   }\r\n> }\r\n> ```\r\n\r\n##### for Cover\r\n\r\n* `cover`\r\n\r\n    Set the value to `false` if you don't need a cover page.  \r\n    **default**: `true`\r\n\r\n* `back_cover`\r\n\r\n    Set the value to `true` if you need a back cover page.  \r\n    **default**: `false`  \r\n    _**since**: `v0.8.0`_\r\n\r\n    You would be better to install the `qrcode` package:\r\n\r\n    ```sh\r\n    pip install qrcode\r\n    ```\r\n\r\n* `cover_title`\r\n\r\n    Set the title text in cover page.  \r\n    **default**: use `site_name` in your project `mkdocs.yml`\r\n\r\n* `cover_subtitle`\r\n\r\n    Set the subtitle text in cover page.  \r\n    **default**: `None`\r\n\r\n* `cover_logo`\r\n\r\n    Set the logo image in cover page. This value is URL or simply specify the relative path to the docs directory.  \r\n    **default**: `None`  \r\n    _**since**: `v0.8.0`_\r\n\r\n##### for Heading and TOC\r\n\r\n* `toc_title`\r\n\r\n    Set the title text of _Table of Content_.  \r\n    **default**: `Table of Content`  \r\n    _**since**: `v0.4.0`_\r\n\r\n* `heading_shift`\r\n\r\n    Set this value to `false`, disable shift heading in child page.  \r\n    **default**: `true`\r\n\r\n    In this flags enable, heading move down one level in child page.\r\n\r\n* `toc_level`\r\n\r\n    Set the level of _Table of Content_. This value is enabled in the range of from `1` to `3`.  \r\n    **default**: `3`\r\n\r\n* `ordered_chapter_level`\r\n\r\n    Set the level of heading number addition. This value is enabled in the range of from `1` to `3`.  \r\n    **default**: `3`\r\n\r\n* `excludes_children`\r\n\r\n    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.  \r\n    **default**: `[]`\r\n\r\n##### for Page\r\n\r\n* `exclude_pages`\r\n\r\n    Set the page `id` of `nav` url. If the `id` matches in this list, it will be excluded page contents.  \r\n    **default**: `[]`  \r\n    _**since**: `v0.3.0`_\r\n\r\n* `convert_iframe`\r\n\r\n    List of `iframe` to `a` conversions. Every `iframe` that matches a `src` in this list will be replace to `a` contains each `img` and/or `text`. it's using for such as embedded VIDEO.  \r\n    **default**: `[]`  \r\n    _**since**: `v0.6.0`_\r\n\r\n    @see [Sample of _MkDocs Material_](https://github.com/orzih/mkdocs-with-pdf/blob/master/samples/mkdocs-material/)\r\n\r\n* `two_columns_level` (Experimental)\r\n\r\n    Set the heading level of **_Two Column Layout_**. Currently only `0`(disable) or `3` is valid for this value. So slow processing, but a little nice.  \r\n\r\n    **default**: `0`  \r\n    _**since**: `v0.7.0`_\r\n\r\n    @see [Sample of _MkDocs Material_](https://github.com/orzih/mkdocs-with-pdf/blob/master/samples/mkdocs-material/)\r\n\r\n##### Renderer for JavaScript\r\n\r\n* `render_js`\r\n\r\n    Set the value to `true` if you're using '[MathJax](https://www.mathjax.org/)', '[Twemoji](https://twemoji.twitter.com/)' or any more.  \r\n    Require \"Chrome\" which has \"headless\" mode.  \r\n\r\n    **default**: `false`  \r\n    _**since**: `v0.7.0`_\r\n\r\n* `headless_chrome_path`\r\n\r\n    Set the \"Headless Chrome\" program path.  \r\n    If `render_js` is _`false`_, this value will be ignored.  \r\n\r\n    **default**: `chromium-browser`\r\n\r\n> Check on your system:\r\n>\r\n> ```\r\n> $ <PROGRAM_PATH> --headless \\\r\n>    --disable-gpu \\\r\n>    --dump-dom \\\r\n>    <ANY_SITE_URL(eg. 'https://google.com')>\r\n> ```\r\n\r\n##### ... and more\r\n\r\n* `output_path`\r\n\r\n    This option allows you to use a different destination for the PDF file.  \r\n    **default**: `pdf/document.pdf`\r\n\r\n* `custom_template_path`\r\n\r\n    The path where your custom `cover.html` and/or `styles.scss` are located.\r\n    **default**: `templates`  \r\n    _**since**: `v0.8.0`_\r\n\r\n* `enabled_if_env`\r\n\r\n    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.  \r\n    **default**: `None`\r\n\r\n    PDF generation can take significantly longer than HTML generation which can slow down mkdocs's built-in dev-server.\r\n\r\n    Adding `enabled_if_env: ENABLE_PDF_EXPORT` under `- with-pdf:` disables PDF generation during development.  Run the dev-server normally:\r\n\r\n    ```sh\r\n    $ mkdocs serve\r\n    INFO    -  Browser Connected: http://127.0.0.1:8000/\r\n    INFO    -  Running task: builder (delay: None)\r\n    INFO    -  Building documentation...\r\n    WARNING -  without generate PDF(set environment variable ENABLE_PDF_EXPORT to 1 to enable)\r\n    ... 2 seconds later ...\r\n    INFO    -  Reload 1 waiters: /.../index.md\r\n    ```\r\n\r\n    and to build files to deploy specify `ENABLE_PDF_EXPORT=1` at the command line:\r\n\r\n    ```sh\r\n    $ ENABLE_PDF_EXPORT=1 mkdocs build\r\n    ...\r\n    INFO    -  Converting 10 articles to PDF took 7.1s\r\n    INFO    -  Documentation built in 8.29 seconds\r\n    ```\r\n\r\n* `debug_html`\r\n\r\n    Setting this to `true` will out HTML to `stdout` on build time.  \r\n    **default**: `false`\r\n\r\n    You can try this:\r\n\r\n    ```bash\r\n    mkdocs build > for_pdf_print.html\r\n    ```\r\n\r\n    ...and browse output with Google Chrome. [Chrome DevTools Into Print Preview Mode](https://developers.google.com/web/tools/chrome-devtools/css/print-preview) will you help.\r\n\r\n    Note: WeasyPrint and Google Chrome are not fully compatible.\r\n\r\n* `show_anchors`\r\n\r\n    Setting this to `true` will list out of anchor points provided during the build as info message.  \r\n    **default**: `false`  \r\n    _**since**: `v0.7.4`_\r\n\r\n* `verbose`\r\n\r\n    Setting this to `true` will show all WeasyPrint debug messages during the build.  \r\n    **default**: `false`\r\n\r\n## Custom cover page and document style\r\n\r\nIt is possible to create a custom cover page for the document.\r\nYou can also add a custom style sheet to modify the whole document.\r\n\r\nTo do so, add a `templates` folder at the root level of your `mkdocs` project and place a `cover.html` and/or a `styles.scss` inside.\r\nAlternatively, you can specify a different location with the `custom_template_path` option.\r\n\r\n### Custom cover page\r\n\r\nUsing [jinja2](https://jinja.palletsprojects.com/en/2.11.x/templates/) syntax, you can access all data from your `mkdocs.yml`.\r\nTo make template creation easier, you can use `plugin_some_plugin` to access variables from plugins.\r\nE.g. use `{{ author }}` to get the author from your `mkdocs.yml` that looks like:\r\n\r\n```yaml\r\nplugins:\r\n    - with-pdf:\r\n        author: WHO\r\n```\r\n\r\nYou can use custom variables [`extra:` in your `mkdocs.yml`](https://www.mkdocs.org/user-guide/configuration/#extra)\r\nAnd, you can check it in the log if run with `verbose` or `debug_html` options.\r\n\r\n### Custom stylesheet\r\n\r\nSince your stylesheet is appended to the default ones, you can override every setting from them.\r\n\r\nTip: setting the `debug_html` option to `true` to get the generated html that is passed to `weasyprint` can help you determine the html tags, classes or identifiers you want to modify in your stylesheet.\r\n\r\n### Advanced Rendering Hooks (Experimental)\r\n\r\nYou can hook the PDF rendering process by creating a `pdf_event_hook.py`(or `pdf_event_hook/__init__.py`) in your working directory _(usually the same directory as` mkdocs.yml`)_.  \r\n_**since**: `v0.8.2`_\r\n\r\n#### Sample `pdf_event_hook.py` (or `pdf_event_hook/__init__.py`)\r\n\r\n```python\r\nimport logging\r\n\r\nfrom bs4 import BeautifulSoup\r\nfrom mkdocs.structure.pages import Page\r\n\r\n\r\ndef inject_link(html: str, href: str,\r\n                page: Page, logger: logging) -> str:\r\n    \"\"\"Adding PDF View button on navigation bar(using material theme)\"\"\"\r\n\r\n    def _pdf_icon():\r\n        _ICON = '''\r\n<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\r\n<path d=\"M128,0c-17.6,0-32,14.4-32,32v448c0,17.6,14.4,32,32,32h320c17.6,0,32-14.4,32-32V128L352,0H128z\" fill=\"#E2E5E7\"/>\r\n<path d=\"m384 128h96l-128-128v96c0 17.6 14.4 32 32 32z\" fill=\"#B0B7BD\"/>\r\n<polygon points=\"480 224 384 128 480 128\" fill=\"#CAD1D8\"/>\r\n<path d=\"M416,416c0,8.8-7.2,16-16,16H48c-8.8,0-16-7.2-16-16V256c0-8.8,7.2-16,16-16h352c8.8,0,16,7.2,16,16  V416z\" fill=\"#F15642\"/>\r\n<g fill=\"#fff\">\r\n<path d=\"m101.74 303.15c0-4.224 3.328-8.832 8.688-8.832h29.552c16.64 0 31.616 11.136 31.616 32.48 0 20.224-14.976 31.488-31.616 31.488h-21.36v16.896c0 5.632-3.584 8.816-8.192 8.816-4.224 0-8.688-3.184-8.688-8.816v-72.032zm16.88 7.28v31.872h21.36c8.576 0 15.36-7.568 15.36-15.504 0-8.944-6.784-16.368-15.36-16.368h-21.36z\"/>\r\n<path d=\"m196.66 384c-4.224 0-8.832-2.304-8.832-7.92v-72.672c0-4.592 4.608-7.936 8.832-7.936h29.296c58.464 0 57.184 88.528 1.152 88.528h-30.448zm8.064-72.912v57.312h21.232c34.544 0 36.08-57.312 0-57.312h-21.232z\"/>\r\n<path d=\"m303.87 312.11v20.336h32.624c4.608 0 9.216 4.608 9.216 9.072 0 4.224-4.608 7.68-9.216 7.68h-32.624v26.864c0 4.48-3.184 7.92-7.664 7.92-5.632 0-9.072-3.44-9.072-7.92v-72.672c0-4.592 3.456-7.936 9.072-7.936h44.912c5.632 0 8.96 3.344 8.96 7.936 0 4.096-3.328 8.704-8.96 8.704h-37.248v0.016z\"/>\r\n</g>\r\n<path d=\"m400 432h-304v16h304c8.8 0 16-7.2 16-16v-16c0 8.8-7.2 16-16 16z\" fill=\"#CAD1D8\"/>\r\n</svg>\r\n'''  # noqa: E501\r\n        return BeautifulSoup(_ICON, 'html.parser')\r\n\r\n    logger.info(f'(hook on inject_link: {page.title})')\r\n    soup = BeautifulSoup(html, 'html.parser')\r\n\r\n    nav = soup.find(class_='md-header-nav')\r\n    if not nav:\r\n        # after 7.x\r\n        nav = soup.find('nav', class_='md-header__inner')\r\n    if nav:\r\n        a = soup.new_tag('a', href=href, title='PDF',\r\n                         **{'class': 'md-header__button md-header-nav__button md-icon'})\r\n        a.append(_pdf_icon())\r\n        nav.append(a)\r\n        return str(soup)\r\n\r\n    return html\r\n\r\n\r\n# def pre_js_render(soup: BeautifulSoup, logger: logging) -> BeautifulSoup:\r\n#     logger.info('(hook on pre_js_render)')\r\n#     return soup\r\n\r\n\r\n# def pre_pdf_render(soup: BeautifulSoup, logger: logging) -> BeautifulSoup:\r\n#     logger.info('(hook on pre_pdf_render)')\r\n#     tag = soup.find(lambda tag: tag.name ==\r\n#                     'body' and 'data-md-color-scheme' in tag.attrs)\r\n#     if tag:\r\n#         tag['data-md-color-scheme'] = 'print'\r\n#     return soup\r\n```\r\n\r\n... and check log:\r\n\r\n```sh\r\n$ mkdocs build\r\nINFO    -  Found PDF rendering event hook module.\r\nINFO    -  Cleaning site directory\r\nINFO    -  Building documentation to directory: /tmp/sample/site\r\nINFO    -  (hook on inject_link: Home)\r\n   ...\r\n```\r\n\r\n## Contributing\r\n\r\nFrom reporting a bug to submitting a pull request: every contribution is appreciated and welcome. Report bugs, ask questions and request features using [Github issues][github-issues].\r\nIf you want to contribute to the code of this project, please read the [Contribution Guidelines][contributing].\r\n\r\n## Special thanks to\r\n\r\n* [Terry Zhao][zhaoterryy] the author of the [MkDocs PDF Export Plugin][mkdocs-pdf-export-plugin] the source of our inspiration. We've used some of his code in this project.\r\n\r\n[mkdocs-pdf-export-plugin]: https://github.com/zhaoterryy/mkdocs-pdf-export-plugin\r\n[zhaoterryy]:  https://github.com/zhaoterryy\r\n\r\n[weasyprint]: http://weasyprint.org/\r\n[weasyprint-linux]: https://weasyprint.readthedocs.io/en/latest/install.html#linux\r\n[weasyprint-macos]: https://weasyprint.readthedocs.io/en/latest/install.html#os-x\r\n[weasyprint-windows]: https://weasyprint.readthedocs.io/en/latest/install.html#windows\r\n\r\n[mkdocs-plugins]: http://www.mkdocs.org/user-guide/plugins/\r\n[mkdocs-material]: https://github.com/squidfunk/mkdocs-material\r\n\r\n[contributing]: https://github.com/orzih/mkdocs-with-pdf/blob/master/CONTRIBUTING.md\r\n[github-issues]: https://github.com/orzih/mkdocs-with-pdf/issues\r\n\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Generate a single PDF file from MkDocs repository",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/orzih/mkdocs-with-pdf"
    },
    "split_keywords": [
        "mkdocs",
        "pdf",
        "weasyprint"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9c7925af785d976b6672f169e6768d602bf688597c307401fb77e80d963519cd",
                "md5": "afdbbfb079516d0f4ad528fc648be4b2",
                "sha256": "47f71bcd3c424a19a8cce82a25a4a0e5dc08fd53744cbb72b8e2256fa21342cb"
            },
            "downloads": -1,
            "filename": "mkdocs-with-pdf-multiply-docs-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "afdbbfb079516d0f4ad528fc648be4b2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 41853,
            "upload_time": "2023-08-29T09:44:24",
            "upload_time_iso_8601": "2023-08-29T09:44:24.224789Z",
            "url": "https://files.pythonhosted.org/packages/9c/79/25af785d976b6672f169e6768d602bf688597c307401fb77e80d963519cd/mkdocs-with-pdf-multiply-docs-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-29 09:44:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "orzih",
    "github_project": "mkdocs-with-pdf",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "mkdocs-with-pdf-multiply-docs"
}
        
Elapsed time: 0.10674s