Re: PostScript files from Cobol
- From: "Richard" <riplin@xxxxxxxxxxxx>
- Date: 20 Apr 2005 03:13:10 -0700
> I released a small cobol library on SourceForge to help generating
> PostScript files from Cobol programs.
Just last week I did some work on creating postscript from Cobol.
Previously I had been doing it with a 2 stage process outputting a text
file of substitution values and then doing a merge of these against a
postscript file created using a drawing program - impress (not the OOo
program of that name). The merge had been written in C.
Having used libps from Python with a templating mechanism I decided
that it would be useful to do in Cobol. Many of the libps routines can
be called, but Fujitsu Cobol for Linux does not allow a floating BY
VALUE to be used in the CALL. I had to write simple C routines to take
a fixed parameter, convert to float and then call libps.
The postscript is only used from templating routines and the template
does all the driving. For example a template may be:
# comments start # in column 1
*PS
*LEFT=8
*TOP=1
# -----------------------------------------------------
:header
*START=0
*USE=11
#box,line,col,len,width,shade=style
#text,line,col,font,b|u|i=text
#line,line,col,width=style
box,2,1,58,65,1.0=white
text,1,1,13=SOME CUSTOMER LTD.
text,1,52,10=Procedure No. 3.4 f1-0
line,1.2,1,65=solid
box,2,1,3,65,0.9=gray
text,4,3,14,b=CORRECTIVE ACTION REQUEST
text,4,34,12=(including preventive action)
text,4,56,12,b=No.<!%carno%>
text,7,3,12=1. Issued to: <!%istoname%>
text,7,30,12=by: <!%issuname%>
text,7,50,12=on: <!%dated.date%>
text,9,3,12=as a result of: <!%codename%> <!%other%>
line,10,1,65=solid
# ----------------------------------------------------------
:standard
*START=+
*USE=5
text,1,3,12=2. Applicable standards and documents: <!%standard%>
line,2.5,1,65=solid
text,4,3,12=3. Description of non-conformance or potential
non-conformance or improvement:
# ----------------------------------------------------------
:reqline
*START=+
*USE=1
text,1,3,12,b=<!%request.line%>
# -------------------------------------
:signon
*START=+
*USE=3
text,2,3,10=Signature of initiator: <!%issuname%>
text,2,36,10=Date: <!%dated.date%>
line,2.5,1,65=solid
# -----------------------------------------------------
:response
*START=+
*USE=2
text,1,3,12=4. Corrective Action / Preventive Action
# ------------------------------------
:respline
*START=+
*USE=1
text,1,3,12,b=<!%response.line%>
# ------------------------------------
:respend
*START=+
*USE=5
text,2,3,10=To be implenented By: <!%donename%>
text,2,36,10=By Date: <!%completed.date%>
text,4,3,10=Proposed By: <!%issuname%>
text,4,36,10=Date: <!%dated.date%>
line,4.5,1,65=solid
# ----------------------------------------------------------
:trailer
*START=+
*USE=2
text,1,3,12=5. Follow-up: <!%satisfy%> <!%newcar%>
# ------------------------------------
:trailine
*START=+
*USE=1
text,1,3,12,b=<!%closing.line%>
# ------------------------------------
:traiend
*START=+
*USE=3
text,2,3,10=Signature: <!%closname%>
text,2,36,10=Date: <!%closed.date%>
line,2.5,1,65=solid
image,3,3,jpeg,1=linfox.jpg
# -----------------------------------------------------------
:end
The program sets up a table of tag + value pairs and then calls the
template routine specifying the section to output. Sections start with
:.
The template program processes each line in the section replacing the
tags <!%name%> with the value from the table that matches to tag
'name'. It then passes each line to the postscript processor which
identifies the object required (box, text, line) and calls libps as
required.
All offsets are line, column (but may be decimal (ie 2.5) with 0,0 as
top left of page (ie inverted from PS). The *START and *USE commands
update the current line offset for each section so that the page builds
down from the top. line and column are relative to offsets which start
at the *TOP and *LEFT commands.
The 'text' specifies font size and style (eg b=bold). 'box' specifies a
fill gray level.
The advantage (IMHO) of this approach is that the program itself only
cares about the data items and the sections, the template file does all
the presentation.
The *PS at the top tells the template program that this uses the PS
routines, it can also output HTML, CSV, or text for printing. This
means that the program need not care what is being output, it only
needs to allow the template file to be selected by some means and then
bang out the sections.
The PS processing code is OO in Fujitsu Cobol for Linux.
.
- Follow-Ups:
- Re: PostScript files from Cobol
- From: Alain Reymond
- Re: PostScript files from Cobol
- References:
- PostScript files from Cobol
- From: Alain Reymond
- PostScript files from Cobol
- Prev by Date: Re: CSF and Mainframe
- Next by Date: Re: CSF and Mainframe
- Previous by thread: PostScript files from Cobol
- Next by thread: Re: PostScript files from Cobol
- Index(es):
Relevant Pages
|