There is no dependency on Unix, although that is all we have used. With minor changes to pdx2ps it would probably work on any platform on which perl is available.
Overview
Postscript Form Generation
Conversion
Application Requirements
Document Conversion
Forms Printing
Document Previewing
Limitations
Links
Download
Contact Us
The method is almost identical to the definition of a form in postscript that can be stored in the memory of a printer and called by your postscript code when needed. However, we print lots of different documents and so this was not the best option.
We have used the term variable in connection with postscript in this document since that will be familiar to Progress programmers. Technically the correct term is definition, since what we are doing is adding a definition to the interpreter’s dictionary (nothing to do with Progress’ dictionary).

In the above example, the form would allow data to be placed in variables named requested-by, req-addr1, req-addr2, req-addr3, req-addr4, req-phone, req-fax and valid-date.
All variables must be entered as a separate text string and they must be the first item in the string. They cannot be part of a sentence, although groups of them can appear together. In the example, the req-addr group was entered as a text object with each line separated by a new line. This is because pdx2ps looks for the sequence (pdx- at the start of a line, which is the case for text entered by itself, but not if it is part of a larger string. The format of the pdx files forces this and is the key to the method’s operation.
If you entered “Item pdx-item cannot shipped” in a form, you would not be able to insert data into a variable called item.
It is important to remember that any positioning of text applies to the text typed on the form at the time of creation. This means you cannot have justification of a variable length string if you have selected a proportional font, since the position is based on the text entered on the form. The workaround is to use a fixed pitch font and justify it yourself in your application.
pdx2ps -i input-file -o output-fileThis script creates an output file with the Mayura Draw font names changed to normal postscript names, all identified variables stripped of their leading pdx- characters and two postscript procedures defined. It also adds some code to print a message across the bottom of the page.
The first procedure created by pdx2ps is called reset-names and simply sets all the variable values to blank. Having this allows the Progress procedure to only produce the required name/value pairs rather than the complete list.
The second procedure is called display-page and this needs to be called for each printed page required. This procedure draws all the elements on the page and prints the data stored in any defined variables.
The message on the bottom of the page is useful in a development or test environment where it is important that the resultant files should not be confused with documents from the production system. The default is to print the word VOID in 200 point outline, but the text can be overridden by redefining the postscript variable message in the output file as follows:
/message (Test) defIn a production environment the message definition should be set to blank to prevent the text being displayed on each page. Do this as shown below:
/message () def
The basic format is as follows:
% CommentsLet's look at this file line by line.
%%Page: page-name sequence-num
reset-names
/token-name (value) def % any number, including none, of defined names
display-page showpage
%%PageTrailer
I suggest that the first line in each generated file be a comment line containing some text saying how it was generated, what it is for, whatever, but this is only if you need to do any sort of debugging of your application. A % sign introduces postscript comments. You must comment each line if more than one is used.
The second line shown is an attempt at supporting Adobe's Document Structure Convention (DSC). This is a convention used to allow structure information to be gleaned from a file. This is not relevant for a printed file, only for displaying it using something like gsview. Page-name is the name of the page and sequence-num is a number indicating the order in which to display the pages. Normally these two numbers would be the same.
The next line calls reset-names, one of the functions defined when pdx2ps is run. Failure to call reset-names will leave the last definition of your variables on the interpreter’s stack. This may be what you want in some situations, especially if a lot of data is being reproduced on each page without change.
Next, each of the required variable definitions should appear, one per
line, with a leading /. token-name is the variable name
you want to use. These strings are case sensitive. If in doubt as to what
the forms designer used look in the main postscript file for the reset-names
procedure and all defined variables will be listed there. The value to
display appears between parentheses followed by def. If your application
does not print properly, this is the first place to start looking for the
cause of the problem. Escape sequences for certain special characters are
shown in the following table.
| Sequence |
|
| \\ | Backslash |
| \( | Left parenthesis |
| \) | Right parenthesis |
| \ before a newline | Allows you to break a string across two lines without inserting a newline
into the string. That is, the string:
(This is a\
is equivalent to the string: (This is a string that has no newlines) |
WARNING: you cannot use array syntax in your variable names. This means that variable[n] where n is an integer is not allowed.
After all the variables have been defined you must then call the second function added by pdx2ps, display-page. You must then call showpage, which is the postscript operator that causes output to be viewed on the output device, in this case a printer.
The last line is %%PageTrailer which is part of the DSC.
The following is a sample from one of our reports.
%%Page: 1 1Be aware that this technique prints the same form on each page. To produce multiple pages using the same form, just repeat the above sequence with the new variable values, making sure you increment the page number and sequence number values.
reset-names
/order-num (W274173) def
/your-ref (Quote 22/2/99) def
/date-raised (27 Feb 1999) def
/date-due (ASAP) def
/contact-name (Peter Bisset) def
/contact-phone (61-7-3247 8553) def
/contact-fax (61-7-3247 8560) def
display-page showpage
%%PageTrailer
Concatenating the converted file with the application generated data file and the small trailer file called pdxtail.ps makes a complete postscript document. In Unix this is simply:
cat pdx2ps-output generated-output pdxtail.ps > final-fileThe file final-file is a postscript file that can be printed or viewed.
If the first page is different to subsequent pages then you simply need to follow the same process with one small change. Mayura Draw doesn’t handle multiple pages so simply make each page as a separate document.
Convert each of the forms for the different pages. Now simply concatenate them with the relevant data file. Finally, append the pdxtail.ps file. For example,
cat file1 data1 file2 data2 data3 data4 pdxtail.ps > final-fileThis will produce a four-page document with a single copy of page one (file1) and the data from data1 placed on it and three pages using the form contained in file2 with data from data2, data3 and data4 placed on each page.
Our application looks at the database record that contains details of the printer at a destination to see if it allows printing of forms. There is a logical field in the record that indicates whether this is a destination that can print forms. If it is we then look at another logical field to see if this printer supports postscript. If it doesn't then we use a character field in the same record as a value to pass to a script called psconv. This script simply calls ghostscript to convert the postscript file to another format with the contents of this character field used to specify the -sDEVICE argument for ghostscript. The syntax for psconv is:
psconv gs-device input-file output-file
If you have documents done in something like Word or Excel, then the best way is to use the Adobe Postscript driver for Windows and direct the output to a file. This file can then be printed directly to a postscript printer without any preprocessing. If you can't get the Adobe driver then the Apple Laser Writer driver provided with Windows produces good postscript. Look at the output from a Windows driver to see why Mayura Draw makes the job easier.
We only print to A4, however it is simple to change the scripts to support
different page sizes. Simply select the relevant paper size from the table
below and alter the setpagedevice call in the conversion scripts. This
table includes the more common paper sizes.
| Point Size | Paper Size |
| [522 756] | Executive |
| [612 792] | Letter |
| [612 1008] | Legal |
| [595 842] | A4 |
| [842 1191] | A3 |
| [297 684] | Com 10 Envelope |
| [312 624] | DL Envelope |
Mayura Draw![]()
Ghostscript & GSview
Progress Software
| psconv | shell script that calls ghostscript to convert postscript files |
| pdx2ps | perl script to convert a Mayura Draw file to one that can take data |
| fixpdx | perl script to convert a Mayura Draw file to generic postscript |
| pdxtail.ps | postscript file to add to the end of a form |
| dummy.ps | dummy placeholder file to use for testing. Simply cat output file, dummy and pdxtail.ps. |
| sample.pdx | a sample Mayura form showing how to specify places for data |
| ransom.ps | this is as close to fun as you can come with postscript :-) |
| fontlist.ps | some postscript code to list the fonts available in a printer (even works on an HP 4MV and gsview) |
| thelot.zip | everything above, including this page. |
Peter Bisset: pbisset@emergency.qld.gov.au
Page Last Updated: 17 November 1999