Last Updated on 14 October 2019 by Roberto De Pedrini
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.
Implementation
Implementing this keyword is quite simple, so much so that only a few variables are needed to manage it:
- resource name: character field that can have a maximum length 250
- resource type: character field of length 10
- top position: numeric field of 5 integers with 3 decimals
- position from the margin: numeric field of 5 integers with 3 decimals
- rotation (optional): numeric field of 3 integers with 0 decimals
- path (optional): character field that can have a maximum length of 2000
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 |
Example
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;
Limitations
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:
- allows you to include up to 10 resources on a single page
- each record can include the keyword AFPRSC at most once
- does not allow combination with the following other keywords:
- SPACEA / SPACEB
- SKIPA / SKIPB
References
For more information, the official IBM documentation is available (https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzakd/rzakdpdf.pdf)
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”