Tips for Manipulating Postscript


Translating postscript files from A4 to US Letter format

Unfortunately, the majority of our documents are in A4 format, while many of our collaborators must use US Letter printers. Here are some ways to translate files from one format to the other:


Extracting figures from postscript files

Postscript files which include figures actually preserve the source of the original eps files intact. You can easily extract the figures ... they are framed by two distinctive lines in the ps file:

	%%BeginDocument
	...
	%%EndDocument
You can extract the eps files by hand in a text editor. Note, however, that the bounding box for the eps figure is lost. (Well, not exactly, but it's a bit complicated to pull it out, and I haven't verified a robust method yet). The easiest thing to do is to simply run ps2epsi on the code you extracted ... it will make the bounding box for you, and insert the usual eps header lines.

Here is a perl script which does all this automatically for you: extract-eps. Basically, you type

	extract-eps file.ps
and all embedded eps files will be extracted (using their original filenames). Type
	extract-eps -h
to learn about a few command line options that are available.


Changing colour postscript to black-and-white

If often happens that you have a lovely colour figure that you would like to render in black-and-white ... for example, a plot that you showed at a talk, but must now include in a printed proceeding. If you don't have a B&W version of the plot at hand, you can convert your colour file. The two simplest choices are:

  1. Take the RGB (red-green-blue) specification of each colour, average the values, and use that as a grayscale setting.
  2. Turn all colours (and any grayscales) to black.
The second option is perhaps better for plots, while the first is more suitable for figures and diagrams. It depends a lot on the particulars of your colour file.

Here is a perl script which performs either of these manipulations: bw_convert. The usage syntax is

	bw_convert [-b] colour-file.ps bw-file.ps
The -b option engages procedure #2 above -- convert all colours and greys to black. Otherwise, procedure #1 is used.


About the perl scripts


The Quest for Wizardry

Postscript is a programming language, just like FORTRAN, C, or PERL. Postscript files are in ASCII text, just like any other source code, and so can be readily hacked ... if you know the language. :-) In fact, it is a rather nice language, extremely similar to that of an RPN calculator -- if you have ever used such a calculator, the syntax of postscript will be perfectly intuitive to you. Here are 4 links that can take you all the way from Acolyte to Wizard:


Maintained by N.C.R. Makins (makins@uiuc.edu)