Desktop publishing applications are able to create print-quality documents. The problem with them is that they often involve fiddling around, or “massaging” as its often referred to as. Combining programming logic with a layout or layout elements can produce a complex document quickly while retaining the the human elements.
In this example, I will use Scribus and Python to generate a document of numbered tickets and corresponding ticket stubs. Dialogs are used to ask the user the starting ticket number and the number of tickets to generate.
Why Use A Desktop Publishing Application
There is a good chance you've needed to use a desktop publishing application but used something else instead. Perhaps you were creating a newsletter, brochure, business cards or a flyer. While using a program like Microsoft Word or Adobe Photoshop can get the job done, they are built as word processors and graphics applications.
A desktop publishing application is designed to create a printed document from a number of elements. Word processors and graphics applications feed their data into the desktop publishing application. The desktop publishing application can export many formats, from PDFs to press-ready colour separations with bleeds and crop marks.
Two common desktop publishing applications are Adobe InDesign and Microsoft Publisher. These are both suitable solutions but this example focuses on Scribus. Scribus is free, and runs on many platforms. While it lack some of the usability of InDesign, it is very similar to older desktop publishing applications such as QuarkXPress. I was a big fan of QuarkXPress and used AppleScript to help build a product catalogue based on a spreadsheet and a folder of EPS images.
Scribus is an open source desktop publishing application that runs on Winodws, MacOS X, Linux and an assortment of other operating systems. It supports the features you would expect from a commercial product used for production. Colour separations, CMYK and spot colours, ICC profiles, PDF export, pre-flight, text flow and many more professional features are included. Most professional software also provides some way of automating production.
Python is a simple and power programming language. It is often used to create web applications, linux desktop applications and even games.
Putting Them Together
The Scribus website has a number of example Python scripts that you can use to learn from. Reviewing the example scripts will help you learn the functionality a bit but it can take a bit of work. What I discovered is that it was easier to create elements on the fly and assign the desired properties to them, rather than try to identify the elements on the page.
I've attached a Scribus template that defines the guides for the tickets. Create a single ticket on the master page. Then, duplicate the ticket 3 times horizontally by 2.125", and all four once by 5.5". You can see those values below in x and y. This will produce a master page with unnumbered tickets. Creating additional pages, whether manually or programmatically, will create 8 more tickets per page. Obviously, this layout uses letter size paper and would need to be adjusted for other paper sizes.
ticketnumdefault = 2014001
ticketcount = int(scribus.valueDialog('Tickets', 'Please enter the number of tickets', '8'))
ticketnum = int(scribus.valueDialog('Ticket Number', 'Please enter the starting ticket number', str(ticketnumdefault)))
page = 1
col = 1
row = 1
for i in range(0, ticketcount):
x = (.125 + (col - 1) * 2.125)
y = (.25 + (row - 1) * 5.5)
A = scribus.createText(x, y, 1.875, .25)
B = scribus.createText(x, y + 4.875, 1.875, .25)
col += 1
if col > 4:
col = 1
row += 1
if row > 2 and i < (ticketcount - 1):
row = 1
pagecount = scribus.pageCount()