Starting from V7R1 IBM has released the keyword AFPRSC usable at record leve
l. It is useful in case you want to insert images, pdf and AFPDS objects natively in spools without the need to use spool transformation sw licenses and offers the possibility, for example, to generate pdf documents in color directly from our rpg programs.
Some examples of use: logos, layout of graphic modules (invoices, sales / purchase contracts, …), written in transparency (eg pro-forma, fac-simile, …) but also catalogs with product images and so on and so forth.
Index
Implementing this keyword is quite simple, so much so that only a few variables are needed to manage it:
All the variables that are inserted in the DDS of the printer file must be defined as use P (data transfer from the program to the system).
If the * PATH attribute is not specified, the operating system will search for the resource in the path specified in the QIBM_AFP_RESOURCES_PATH environment variable and as the last default in the IFS / QIBM / UserData / OS400 / AFPresources folder.
Here is the list of supported types (resource type):
Type | Description | Note |
* JFIF | Image jpg | |
* PDFSPO | Single page pdf object | It must be smaller than a page |
* PDFSPOTR | Like the previous one but it is printed in transparency | Everything that is written later is superimposed on it |
* PCLPO | PCL object | |
* BCOCA | AFPDS barcode object | |
* GOCA | Graphic object AFPDS | |
* IOCA | AFPDS image object | |
* TIFF | TIFF image |
Here is a simple example of how to implement the DDS keyword of the printer file to print a logo saved in pdf on IFS:
A R RESOURCE AFPRSC (& RESNAME & RESTYPE & POSDOWN +
A & POSACROSS +
A (* ROTATION & ROTATION) +
A (* PATH & PATH))
TO RESNAME 125A P
A RESTYPE 10A P
A POSDOWN 5S 3P
A POSACROSS 5S 3P
A ROTATION 3S 0P
A PATH 640A P
and below the corresponding rpg code block
// directory containing the pdf file to include in the printPATH = '/ home / resources /';
// pdf file nameRESNAME = 'fac-simile.pdf';
// guyRESTYPE = '* PDFSPOTR';
// position downPOSDOWN = 0.5;
// position across
POSACROSS = 0.5;
// degrees of rotation
ROTATION = 0;
// print record
Write RESOURCE;
This keyword opens up new horizons for the production of graphic prints with little effort. In any case, like any other sw component, it has limits, although in my opinion not stringent:
For more information, the official IBM documentation is available (https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzakd/rzakdpdf.pdf)
Debugging functions with Visual Studio Code have been available for some time but this new version 2.10.0 simplifies the handling…
Two and a half years after my post Transferring objects with ObjectConnect and Enterprise Extender, I finally got around to…
With a little trick even a simple SELECT statement can execute any system command! Let's see how to do that...
A mini-serial guide to configuring, managing, using, and troubleshooting the IBM i NetServer
A mini-serial guide to configuring, managing, using, and troubleshooting the IBM i NetServer
A mini-serial guide to configuring, managing, using, and troubleshooting the IBM i NetServer
View Comments
This is a good informative article. I am trying to use AFPRSC with *PDFSPO but it is not working for me. I am getting no errors however the blank report.
Ciao Amit and thank you for your feedback.
Have you tried to use the pdf with transparency (*PDFSPOTR)?
And tryed to print pdf and text in combination?
Please check the dimension (pixel or Mb) of the pdf you are printing.
You can also refer to IBM site (https://www.ibm.com/docs/en/i/7.4?topic=80-afprsc-afp-resource-keyword-in-printer-files) in particular the paragraph "How the operating system searches for resources on the path-to-use or the secondary-resource-path parameter"