Advertisement


How to automate the process of filling diplomas?


Question

Here is a task: I have excel file with table (for example columns are Name, Number and Address) and dimloma template. How can I automate filling my template and save all done diplomas to different files? Which way is the best to do this?

I currently working in Corel Draw. Corel Draw have Print Merge, but it's working with printing on paper, but I need saved files on my desktop. Is it possible in Corel Draw?

2014/06/04
1
0
6/4/2014 6:16:00 AM

Accepted Answer

The easiest solution would probably be to install a PDF printer (such as PDFCreator: http://sourceforge.net/projects/pdfcreator/) and use the Print Merge feature to print to a PDF file, then use an application such as jPDFTweak (http://jpdftweak.sourceforge.net/) or pdftk (http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/) to burst the document into single pages if you need separate files for each diploma.

However, in the past I did this in a different way:

You can save the diploma template as SVG, which is just a text file, and use placeholder strings instead of names. Then, using a script that reads the list of names from a CSV (a text file format which you can save from Excel), you can use text search and replace functions to replace the placeholder strings in the SVG file with actual names. Finally you can use e.g. Inkscape from the command line to convert all the files to a different format.

Note that if you don't know any scripting language, the PDF printer solution will be easier for you; this answer is mainly intended for other people who might be using software without a dedicated Print Merge feature.

Here is an example Python script to generate the SVG files with replaced names. It expects an SVG diploma template called "template.svg" that contains text objects with the text FIRSTNAME and LASTNAME as placeholders, and a CSV file called "recipients.csv" with column names "FirstName" and "LastName" and fields separated by commas.

#!/usr/bin/python
# coding: utf-8

import csv

template_f = open('template.svg', 'r')
template = template_f.read()
template_f.close()

recipients = csv.DictReader(open('recipients.csv', 'rb'), delimiter=',', quotechar='"')
t = template[:]
nfiles = 0

def write_file(content, num):
    output = open('diploma_%02d.svg' % num, 'w')
    output.write(content)
    output.close()

for recipient in recipients:
    firstname = recipient['FirstName'].strip()
    lastname = recipient['LastName'].strip()
    t = t.replace('FIRSTNAME', firstname).replace('LASTNAME', lastname)

    write_file(t, nfiles)
    t = template[:]
    nfiles += 1
1
6/4/2014 7:37:00 AM