Skip to main content
=========
Burocracy
=========

Burocracy is a library that allows you to use .docx templates as
templates using MailMerge fields and can save them as docx's or pdfs. It
can insert plain text, images, tables and (simple) HTML. See
`django-bureaucracy`_ for some mild django integration.

WIP: PPTX as templates.

Usage
=====

Example
-------

.. code-block::

from bureaucracy import DocxTemplate, HTML, Image, Table

doc = DocxTemplate('examples/sample.docx')

context = {
'table': Table(data=[['this is the first cell of the first row', 'this is the second cell of the first row'],
['the second row', 'etc'],
['etc', 'etc]],
headers=['header 1', 'header 2']),
'image': Image('pigeon.jpg')
'html': HTML(<p><strong>bold</strong>-notbold</p><ul><li>hop</li><li>la</li><li>kee</li></ul>")
'text': 'some text',
}

doc.render_and_save('generated.docx', context)
doc.render_and_save('generated.pdf', context, format='pdf')


Inserting mail merge fields
---------------------------

Bureaucracy expects the .docx-files passed to the ``DocxTemplate`` constructor
to contain MailMerge fields whose names correspond to the ones used
in the context dict. How this is done exactly depends on the version of
Office you have, but it seems that it's always a variation on
Insert > Field > Mail Merge > Mergefield and then entering the name:

.. figure:: docs/mailmerge_mac.png?raw=true
:alt: Mailmerge on Mac

What it looks like on Office Mac 2015


Installation
============

.. code-block:: bash

pip install burocracy


Note that although this will install the pypandoc dependency, that package
makes use of the pandoc executable whose installation sometimes fails.
To work around this, install pandoc on it's own with your favorite package
manager and make it available on the path.

For the pdf generation, bureaucracy needs the LibreOffice ``soffice`` executable
to be installed and on the path.


.. _django-bureacracy: https://bitbucket.org/maykinmedia/django-bureaucracy

Metadata

Release files for burocracy 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for burocracy 0.4.1
File Size Uploaded
burocracy-0.4.1.tar.gz 14.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for burocracy 0.4.1
File Interpreter ABI Platform
burocracy-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 34.1 kB

Release files / burocracy-0.4.1.tar.gz

Download URL burocracy-0.4.1.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5c808b07789669747bf018cd754675f7041c1bbea298b126076935672edf7273
BLAKE2b-256 checksum
How to use checksums
a23836f8d3826c9d77c6acf0684389e4c9f9cf34a150f6da840bb792ceedc67b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / burocracy-0.4.1-py3-none-any.whl

Download URL burocracy-0.4.1-py3-none-any.whl
Size 19.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2dce04d3759ec2c169376878425a3d98ada3968a1182b6a46933900f83998cdc
BLAKE2b-256 checksum
How to use checksums
f5a2ad69da7a36e6f11d02d3f466660ef0b10d195a3a3db8b5705d0c25ca58bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2

2 release files

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page