I have tried Ghostscript installed in PASE and it works very nice.

The RPG program instead of printing to a print file, writes Postscript code
to a physical file that later gets post processed with Ghostscript to add
a logo and signatures.

Here's how the driver CL program looks like:

Pgm &y1

Dcl &y1 *Dec (4 0)

/* Postcript program segments */

CpyF MYLIB/QTXT2 XX55F90 FromMbr(XX55F90) MbrOpt(*Replace) FmtOpt(*CVTSRC)
CpyF MYLIB/QTXT2 XX55F99 FromMbr(XX55F99) MbrOpt(*Replace) FmtOpt(*CVTSRC)
CpyF MYLIB/QTXT2 XX55F910 FromMbr(XX55F910) MbrOpt(*Replace) FmtOpt(*CVTSRC)
CpyF MYLIB/QTXT2 XX55F911 FromMbr(XX55F911) MbrOpt(*Replace) FmtOpt(*CVTSRC)
CpyF MYLIB/QTXT2 XX55F95 FromMbr(XX55F95) MbrOpt(*Replace) FmtOpt(*CVTSRC)

/* Output (flat file, 256 record length)

ClrPFM XX55F2
Call XX55R1 &y1

/* To PASE world */

CpyToStmF FromMbr('/QSYS.LIB/MYLIB.LIB/XX55F2.FILE/XX55F2.MBR') +
ToStmf('/home/Sample/var/XX55F2') +
CvtDta(*Auto) StmFOpt(*Replace) StmFCCSID(*StdASCII)

/* convert Postscript to PDF and add passwords */

Call QP2SHELL ( +
'/QOpenSys/usr/local/bin/gs' +
'-sOutputFile=/home/Sample/var/XX55F2.pdf' +
'-sDEVICE=pdfwrite' +
'-sOwnerPassword=*******' +
'-sUserPassword=*******' +
'-dBATCH' '-dNOPAUSE' +
'/home/Sample/var/XX55F2' +
)

Del '/home/Sample/var/XX55F2'

EndPgm


The Postscript template programs are "tagged" and the RPG will replace
the tags with the required values.
Some calculations are made in Postscript like pie chart drawings, totals, etc.

The RPG will generate the file like this:
- Read the postscript preamble file once (*INZSR or first P file) and write to XX55F2
-- Read a record from the database file required to print
--- Read the recurring template portion replacing the tags with the data from the databas file
and write to XX55F2
--
- Read the final template and write it to XX55F5

A piece of the RPG:

*************** Beginning of data *************************************
0001.00 H/TITLE
0002.00 H DFTNAME(XX55R1) DATFMT(*ISO)
0003.00 H DFTACTGRP(*NO) ACTGRP(*CALLER) ALWNULL(*USRCTL)
0004.00 H BNDDIR('TXTUTILS':'NAMES')
* - - Postscript Preamble (contains all your common procedures/def, no tags except for globals)
FXX55F90 IPE F 256 DISK
* - - Your file to print with the data
FINPUTFILE ISE E K DISK PREFIX(H)
* - - Postscript Ending/Closing (no tags)
FXX55F99 ISE F 256 DISK
* - - Postscript sections with tags to generate one page per record in INPUTFILE
FXX55F95 IF F 256 DISK
* - - Output
FXX55F2 O F 256 DISK
* - -

Here's a sample of QTXT2/XX55F95 (read once per record in INPUTFILE)

0001.00
0002.00 /a_name (Name: *NAME) def
0003.00 /a_hird (Date of hire: *HIRD) def
0004.00 /cap_saja (*CAP_SAJA) def
0005.00 /cap_caj2 (*CAP_CAJ2) def
0006.00
- - - - ------------- 4 data records excluded ---------------------------------
% Logo
0011.00 lm 1 add 716 Simbolo
0012.00
0013.00 /Helvetica findfont 10 scalefont setfont
0014.00 394 756 alto sub moveto a_name show
0015.00 394 756 alto 2 mul sub moveto a_hird show
0016.00

Simbolo, alto (and many others) are defined once in the preamble.
For example in Simbolo I use a logo that I got in EPS (encapsulated postscript)
format, but needed to be scaled to 0.2 of the original size.
x and y are the parms representing the coordinates where you want it to be placed on the page.

0034.00 /Simbolo {
0035.00
0036.00 /y exch def
0037.00 /x exch def
0038.00
0039.00 save gsave
0040.00 x y translate
0041.00 0.2 0.2 scale
0042.00 /showpage {} bind def
0043.00 (/home/Sample/var/XXYY_512_376.eps) run
0044.00 grestore restore
0045.00
0046.00 } def

Here's a sample of signature that will accept coordinates x,y using another EPS
with the signature image (yy.eps).

0037.00 /Firma {
0038.00 /y exch def
0039.00 /x exch def
0040.00 save gsave
0041.00 x y translate
0042.00 1.00 1.00 scale
0043.00 /showpage {} bind def
0044.00 (yy.eps) run
0045.00 grestore restore
0046.00 } def

The final result is amazingly precise.

El Mon, 21 Mar 2016 11:20:23 -0500
Vernon Hamberg <vhamberg@xxxxxxxxxxxxxxx> escribió:
Hi Tom

I'm looking at a somewhat-related issue - inserting PNG signatures into
an existing PDF created using one of the techniques, such as OVRPRTF or
MMAIL's commands.

I'm looking at iText, a Java PDF library. I saw some examples of
embedding a link using that library.

There were also examples of putting an image where I want it and resize
and all.

It'd probably require some Java chops to make something callable from
RPG without doing a zagillion method calls out of RPG.

HTH
Vern

On 3/21/2016 11:00 AM, Tom wrote:
(system V6r1m1)



I have a program which creates PDFs from a qsysprt override, it's been
working well for weeks. Client now wants to include within the generated
PDF some links to various webpages on their webserver. The link is to look
something like 'AB-CC-00001', and when the user clicks the link a webpage
opens at the referenced page.



I'm fairly certain that what I'm doing now (override qsysprt to pdf) will
not get the job done, and that I'll need some other utility.



Some recommendations?



Thanks,

TomH








As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.