Skip to main content

Problem:

Can a COBOL Application create PostScript files?

Resolution:

The Server Express COBOL system doesn't contain any PostScript features or functionality however it is possible to generate a PostScript file from within a COBOL application by using Server Express' ability to pipe output to external commands/applications.

Create a SELECT statement like the following

SELECT OUTPUTFILE ASSIGN TO ">  enscript -r -Picl2 -o out.ps"

Organization LINE SEQUENTIAL.

Then create an FD for the file:

FD OUTPUTFILE.

01  OUT-RECORD  PIC X(256).

In the procedure division:

OPEN OUTPUT OUTPUTFILE

MOVE "SOME TEXT" to OUT-RECORD

WRITE OUT-RECORD

.

.

.

CLOSE OUTPUTFILE.

.

.

.

Ths should produce a file named out.ps that us a PostScript file suitable for printing or use with PostScript friendly applications.

Note: If the enscript command is not available , there are several suitable alternative conversion utilities available that can be used in a similar fashion.

Old KB# 3146