Skip to content

Commit 61f433b

Browse files
committed
Update README
The split is complete, and these instructions work with our templates.
1 parent 18a60d0 commit 61f433b

1 file changed

Lines changed: 57 additions & 58 deletions

File tree

README.md

Lines changed: 57 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,72 @@
1-
# kpc-sponsorship
1+
# pdfbaker
22

3-
Creates a [Kiwi PyCon](https://kiwipycon.nz/) sponsorship prospectus and material specs
4-
documents for different sponsorship tiers in PDF format.
5-
6-
The main branch has a year tag for the version that is/was used for that particular
7-
year's conference, like
8-
"[2025](https://github.com/pythonnz/kpc-sponsorship/releases/tag/2025)".
3+
Creates PDF documents from YAML-configured SVG templates.
94

105
## Requirements
116

12-
- [Roboto fonts](https://fonts.google.com/specimen/Roboto) - the font we use
13-
- [Jinja2](https://jinja.palletsprojects.com/en/stable/) (>=3.1.3) - to render the SVG
14-
templates
15-
- [Inkscape](https://inkscape.org/) - to convert SVG to PDF
16-
- [pypdf](https://pypdf.readthedocs.io/en/stable/index.html) (>=4.3.1) - to assemble PDF
17-
pages to a document
18-
- [Ghostscript](https://www.ghostscript.com/) - for PDF compression
7+
For the conversion from SVG to PDF you need to install either
8+
9+
- [CairoSVG](https://cairosvg.org/)<br>
10+
```
11+
sudo apt install python3-cairosvg
12+
```
13+
14+
or
15+
16+
- [Inkscape](https://inkscape.org/)<br>
17+
```
18+
sudo apt install inkscape
19+
```
20+
21+
If you want to compress your PDFs, you will also need to install
22+
23+
- [Ghostscript](https://www.ghostscript.com/)
24+
```
25+
sudo apt install ghostscript
26+
```
27+
28+
## Installation
29+
30+
pdfbaker is on [PyPI](https://pypi.org/project/pdfbaker/) and we reommend installing it
31+
using [pipx](https://github.com/pypa/pipx):
1932

2033
```
21-
sudo apt install fonts-roboto
22-
sudo apt install python3-jinja2
23-
sudo apt install inkscape
24-
sudo apt install python3-pypdf
25-
sudo apt install ghostscript
34+
pipx install pdfbaker
2635
```
2736

28-
The two Python dependencies can also be installed with pip:
37+
If you don't yet have pipx,
38+
[install it first](https://pipx.pypa.io/latest/installation/):
2939

3040
```
31-
pip install -r requirements.txt
41+
sudo apt install pipx
42+
pipx ensurepath
3243
```
3344

34-
The requirements file installs at least the versions that currently get installed by the
35-
above system packages on Ubuntu 24.10.
36-
3745
## Usage
3846

39-
Generate all documents with:
47+
Generate your documents with:
4048

4149
```
42-
python3 -m generate
50+
pdfbaker <path_to_config_file>
4351
```
4452

4553
This will create a `build/` directory and a `dist/` directory (both ignored by git).<br>
4654
It will produce your PDF files in the `dist/` directory (and leave some artifacts in the
4755
`build/` directory, mainly for debugging).
4856

49-
## Structure and Workflow
57+
## Configuration
5058

51-
A total of 6 documents are generated:
52-
53-
- Sponsorship Prospectus
54-
- Material Specs - Diamond
55-
- Material Specs - Platinum
56-
- Material Specs - Gold
57-
- Material Specs - Silver
58-
- Material Specs - Bronze
59+
**FIXME: This is hard to find useful without seeing an example.**
5960

6061
A **document** is made up of **pages**.<br> Pages take their layout from **templates**,
6162
and their specific content from your **configuration**. They may also include
6263
**images**.
6364

65+
Your configuration file can describe multiple documents, each having further
66+
configuration and files in their own directory next to the configuration.
67+
68+
Each document directory consists of:
69+
6470
- `templates/`<br> contains `.svg.j2` files describing the layout of a page. These are
6571
Jinja2 templates which are used to render pages in SVG format, which then gets
6672
transformed into PDF.<br> They contain placeholders for text and images.<br> You only
@@ -76,27 +82,21 @@ and their specific content from your **configuration**. They may also include
7682
- `images/`<br> contains the actual image files referenced in the `.yml` files for
7783
pages.
7884

79-
- `config/`<br> contains the configuration of all documents. It describes which pages
80-
make up a document and in which order, and what specific content to insert. Common
81-
configuration is in `common.yml`, document-specific configuration in their respective
82-
files.<br> You will at the very least need to to adjust the year for your next
83-
conference in `common.yml`.
84-
85-
- `generate/`<br> Contains the code for generating documents.<br> The main entry point
86-
for invoking the generator is in `__main__.py`. Common functionality is in
87-
`common.py`. Helper functions for rendering the SVGs with Jinja are in `render.py`.
88-
Each document gets its own separate module under `documents/`.<br> Documents are
89-
generated using the above framework. A top-level `build/` working directory and a
90-
`dist/` directory for the final results will be created. If they already exist they
91-
will be wiped clean.<br> In the `build/` directory, it will create individual `.svg`
92-
files for each page, convert them to `.pdf` files, and then combine them into a single
93-
`.pdf` file for each document and place them in the `dist/` directory. The prospectus
94-
PDF will also be compressed.
95-
96-
Note: You need to follow a consistent naming convention.
97-
`generate/documents/prospectus.py` will be given the combined configuration of
98-
`config/common.yml` and `config/prospectus.yml`. It will take its pages from
99-
`pages/prospectus/`. Do the same for any new documents you may add.
85+
- `config.yml`<br> contains the configuration of the document (and possibly its
86+
variants). It describes which pages make up the document and in which order, and what
87+
specific content to insert. When your templates are processed, this document-specific
88+
configuration will be merged with your main configuration file, so you can keep
89+
settings in the latter to share between different documents.
90+
91+
- `bake.py`<br> Contains the code for generating your documents.<br> It will create
92+
individual `.svg` files for each page, convert them to `.pdf` files, and then combine
93+
them into a single `.pdf` file for each document and place those in the `dist/`
94+
directory. Where configured to do so, your PDF will also be compressed.
95+
96+
While you have to write the document generation yourself in `bake.py`, it is little code
97+
and gives you full control - for example, one document may create just one PDF file but
98+
another might creates half a dozen variations of itself. All that logic is in your
99+
`bake.py`.
100100

101101
## Development
102102

@@ -112,5 +112,4 @@ commit.
112112

113113
## Known Issues
114114

115-
See [Github Issues](https://github.com/pythonnz/kpc-sponsorship/issues) for known
116-
issues.
115+
See [Github Issues](https://github.com/pythonnz/pdfbaker/issues) for known issues.

0 commit comments

Comments
 (0)