Private Homepage of Hartmut Henkel

Converting tpic \special's into \pdfliteral's by awk

This is just an informal write-up from my private experimenting. I used this example to learn some first basics in writing pdf code for inclusion in pdfTeX \pdfliteral{} parts.

What the awk script presented here does: We start from one or more graphics described by the venerable pic language. The pic code is inline pdfTeX code, limited by classical .PS and .PE markers as known from groff. This TeX file is piped through the (groff-)pic preprocessor and the tpic2pdftex.awk script, which you find below. The result is a TeX file with inline \pdfliteral{} sections, for processing by pdfTeX.

I believe that similar functionality with better quality you get from the ConTeXt macro package, which allows conversion of tpic \specials into an intermediate MetaPost file.

The awk method might be a little bit more straight-forward and faster. Anyway, it's always fun to play with small languages, especially when there is some graphical output.

Software I used was GNU pic (groff) version 1.18.1, and pdftex Version 3.14159-1.10a-devel (Web2C 7.3.9) from teTeX-beta-20021022 on a debian woody (3.0) PC.

You find here the following files (no warranty, play with them on your own risk):

For Usage see file tpic2pdftex.awk.

This example could obviously be extended to support also the dvipdfm path. Or converted into a nice Perl or Python script (I still like the barebones awk). I have never played with the eepic macros, which also produce tpic \special's, and with some modification these might also be processed by the awk script.

Or some time there might be a pdftex driver within the pic preprocessor...

Have fun!

This page first put online 16 October 2002.

News