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 PA RESTYPE 10A PA POSDOWN 5S 3PA POSACROSS 5S 3PA ROTATION 3S 0PA 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 acrossPOSACROSS = 0.5;// degrees of rotationROTATION = 0;// print recordWrite 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)
👉 Review: Bob Cozzi’s RPG IV to RPG Free Conversion – a useful VS Code extension for RPG modernization If…
Hello everyone, I’d like to highlight another excellent contribution by Massimo Duca, part of his ongoing IBM i & SQL…
Intrigued by some recent posts from Cristian Larsen on LinkedIn (New Release – Display File DDS Edit v 0.10.1), I…
Hello everyone, Today I’d like to draw your attention to a major new announcement from IBM: Project Bob — a…
I want to share with you a particularly useful article by Massimo Duca in the IBM i & SQL Tips…
Hello everyone, I’d like to highlight a very useful article by Marco Riva on Markonetools, where he clearly explains how…
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"