- CSV data input.
- Parses SVG properly: no nasty hacked search and replacing.
- Supports multiple data rows per page (just set up your SVG page appropriately).
- Multiple page PDF output.
- Text fields only.
- An individual text field must be on a single line (we modify just the
tspan
tag). - Cannot combine with other uses of the
class
attribute due to dumb XPath query (pull requests welcome).
- Create text fields using Inkscape. Populate them with a single line of text.
- Go to "Edit->XML Editor" in Inkscape.
- Select a text field, and then open it up to find the
tspan
tag. - Name your text field by adding an attribute of key
class
. The value of the attribute can be a field name of your choice. - Group the text fields and any other design elements together.
- Select the group.
- In the XML Editor, add an attribute of key
class
with a value oftemplate
. - Use "Edit->Clone->Create Tiled Clones" or similar to create multiple instances if required.
- Save this file as your master template.
- Before passing this through the mail merge program, you must use "Edit->Clone->Unlink clone" on any clones that are used for templates. This is so that each template can be changed independently in the merge. Save this as a different temporary file to feed to the merge. This way you can continue to use your master template's linked clones to make later changes if necessary.
- Prepare a CSV file. There must be a heading row with fields that
match your field names (the
class
attributes you added earlier). - Run
python3 generate.py input.svg input.csv output.pdf
This program requires Inkscape, Ghostscript, Python 3 and the Python
lxml module. On Ubuntu, you can install these with sudo apt install inkscape ghostscript python3 python3-lxml
.