Postfix Postscript

July 11, 2006

Whew, I’m pretty pleased with myself at the moment. Why? I just hacked some Postscript and it actually worked!

We print our award certificates here at the uni using Postscript generated from a SITS:Vision SRL (I know, I know). Anyway, the issue blew up again of not being able to print superscript or subscript text on research thesis titles. This time I decided I would have a look at what was involved.

Postscript is hard for me to get my head round. It’s uses postfix notation and everything works on stacks: not what I’m used to at all. So for example to print the result of 3 + 2 you have to do: 3 2 add show. Weird huh? And who would guess that this little lot concatenates two strings:

/concatstrings % (a) (b) -> (ab)
   { exch dup length
     2 index length add string
     dup dup 4 2 roll copy length
     4 -1 roll putinterval
} bind def

Although actually doing superscript/subscript is fairly trivial in Postscript, the difficult bit is interpreting when to do it whilst at the same time running a word-wrapping procedure and respecting line-breaks in the existing award title. I ended up completely rewriting the word-wrap code to build this in, but it’s left us with a more flexible routine which is capable of interpreting various HTML-style tags to achieve different effects. Took a day and a half, but it was worth it, even if we do only have one certificate that needs superscript!

Now all we need to do is work out how to get the thesis titles from the Research module into the right place for the certificate creation programs to pick it up. At the moment this is a manual job for registry staff, which is crazy. I feel a modification request coming on.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: