Create PDF from Sphinx using WeasyPrint.
Find a file
2020-06-17 20:25:21 +02:00
build/lib/sphinx_weasyprint_builder Send WeasyPrint logs to Sphinx logger 2020-06-17 20:25:21 +02:00
sphinx_weasyprint_builder Send WeasyPrint logs to Sphinx logger 2020-06-17 20:25:21 +02:00
.gitignore First commit 2020-06-10 22:14:35 +02:00
AUTHORS First commit 2020-06-10 22:14:35 +02:00
babel.cfg First commit 2020-06-10 22:14:35 +02:00
CHANGES First commit 2020-06-10 22:14:35 +02:00
LICENSE First commit 2020-06-10 22:14:35 +02:00
LICENSE-de First commit 2020-06-10 22:14:35 +02:00
LICENSE-fr First commit 2020-06-10 22:14:35 +02:00
LICENSE-nl First commit 2020-06-10 22:14:35 +02:00
README.rst Send WeasyPrint logs to Sphinx logger 2020-06-17 20:25:21 +02:00
requirements.txt First commit 2020-06-10 22:14:35 +02:00
setup.cfg First commit 2020-06-10 22:14:35 +02:00
setup.py First commit 2020-06-10 22:14:35 +02:00

Sphinx WeasyPrint builder
=========================

Sphinx WeasyPrint builder is a PDF generator for
`Sphinx <https://www.sphinx-doc.org>`_ without usage
of LaTeX.

Install
-------

You can install it with `pip`:

.. code:: bash

   pip install sphinx_weasyprint_builder

Or with `setup.py`:

.. code:: bash

   python setup.py install

Configuration
-------------

You can configure your output with these options:

- weasyprint_basename
- weasyprint_theme
- weasyprint_theme_options
- weasyprint_title
- weasyprint_theme_path
- weasyprint_short_title
- weasyprint_style
- weasyprint_css_files
- weasyprint_show_copyright
- weasyprint_show_sphinx

Each one has the same behavior of its equivalent
for `html` builder.

.. warning::

   Your theme must support print media, you can
   have a lot of troubles due to bad CSS. Please
   refer to the WeasyPrint documentation to know
   how to write CSS for printing. For example,
   WeasyPrint can't create scrollbars and some
   text overflows the page.

   You can use the sphinx_weasyprint_theme installed
   with this plugin to start.


Use
---

Just launch the following:

.. code:: bash

   make weasyprint

Signing
-------

.. warning::

   You need to install `pykcs11` and `endesive` to
   sign PDF.

Following parameters are needed to sign:

.. code:: python

   weasyprint_sign_method = 'pkcs11'
   weasyprint_sign_certid = '0x..........'
   weasyprint_sign_reason = 'My Company'
   weasyprint_sign_location = 'Where I am'
   weasyprint_sign_contact = "Yeah, it's me"
   weasyprint_sign_image = 'path_to_image'
   weasyprint_sign_text = __('Signed on {sign_date}\nat {sign_location}\nby {sign_contact}\nfor {sign_reason}') #default
   weasyprint_sign_position = (page, x, y) #default: None

.. note::

   Signing methods are really limited. Do not
   hesitate to contribute !

   Available: `none` (no signing), `pkcs11`

   To be implemented: `p12`, `gpg`

Why an other PDF builder for Sphinx?
------------------------------------

LaTeX is really hard to use and to personalize.
There's also an other project to make PDF without
LaTeX.

WeasyPrint converts HTML to PDF. It's the easiest
way to customize theme and use a constant quality
whatever the media is. If your HTML theme doesn't
have any JavaScript, you can imagine use the same
as HTML and PDF output.

This plugin is just `singlehtml` output with
conversion to PDF.