Where to Discuss?

Local Group


Prepare an inkscape automation for mass product certificate.

We are going to make a mass production of certificate, using python in inkscape. This require a mailmerge like feature, which has not exist yet in inkscape. Actually mailmerge will be exist soon, but we are not there yet.

Step by step?

However, we can use alternate approach with these step below.

  1. Prepare the design using inkscape.

  2. Prepare prepopulated name data in python.

  3. Using inkscape extension: duplicate layer.

  4. Using inkscape CLI: export each layer above.

The Needs

But why do I even bother with automation, while I can do it manually?

The reason is human tend to err when in comes to tedious task.

Well.. Not all people. But at least I know that, I make so many mistake when I’m tired. Sometimes I break, when I haven’t got enough sleep. Fatique is not a myth.

The second reason is I love coding better than tedious task. It is not boring to discover something new.

Prepare the Design

The SVG File

Consider our previous design. It is still a simple design, with a little visual enhancement.


Certificate Test Bed

We need to separate the duplicated layer from other. So we need a root layer. Consider name the the layer Container.

All Layers

Put the replacable text in a special layer. Consider name the layer Template. And then hide the layer visibility using the eye toggle.

Template Layer

The looks of the certificate should looks as below:

Certificate Template Layer Hidden

Keep the Template layer hidden, and save.

XML Properties

Consider have a look at the XML properties:

Layer Template in XML Editor

Notice that there is a child the text, and a grandchild the tspan. And also there are three ids: layer, text, and tspan. We are going to name the layer id and tspan id, using inkscape extension.

Now we are ready to go to the coding part using python.

Prepopulated Data.

What Data?

We only need three data.

  1. ID, maybe number or anything. For use in XML as explained above..

  2. Name, such as full name. For layer name, and also for file naming later.

  3. Name with Title. As replacable text, for use in certificate.

  4. You can also add additional data. But for this example case, let’s keep this case simple.


Certificate will be give for trainees. So we have to setup a file.

Consider name the python file as testbed.py.

#!/usr/bin/env python

people = {
  1: ["Other Data","Brian May","Brian May, PhD"],
  2: ["Other Data","Jim Morrison","Jim Morrison, BSc"],
  3: ["Other Data","Lisa Loeb","Lisa Loeb, BA"],
  4: ["Other Data","Tom Morello","Tom Morello, BA"],
  5: ["Other Data","Greg Graffin","Greg Graffin, PhD"]

Testing in CLI

Before we get into a complex extension coding, it is better to start with CLI.

Consider name the python file as show-people.py.

#!/usr/bin/env python

from testbed import people

for key, person in people.items():
  number     = str(key).zfill(2)
  name_only  = person[1]
  name_title = person[2]

  # layer related
  layer_id   = 'person-id-' + number
  layer_name = number + ' - ' + name_only
  # display name
  text_id   = 'display-id-' + number

  # just another newline


With the result simply as below:

01 - Brian May
Brian May, PhD

02 - Jim Morrison
Jim Morrison, BSc

03 - Lisa Loeb
Lisa Loeb, BA

04 - Tom Morello
Tom Morello, BA

05 - Greg Graffin
Greg Graffin, PhD

ViM: show-people.py

XML Properties

If you wonder, what I’m going to achieve. It is shown here in the XML properties:

Layer Template ID in XML Editor

You can compare with the result of python code above as below:

01 - Brian May
Brian May, PhD

What is Next ?

Consider continue reading [ Inkscape Automation - Part Two ].

Thank you for reading.