Including Dynamic Images in Spooled File Conversions to PDF
CoolSpools command CVTSPLPDF allows you to easily convert your IBM i (AS/400) Spooled File reports to PDF documents, saving the generated PDF documents to the server’s IFS, or distributing those documents using FTP or as email attachments.
The command parameter INCLFILE() allows you to specify the path of one or more JPEG or GIF image files that are to be included in the generated PDF document. Often these are static images that are the same on every page of the generated PDF document, such as a company logo or a form that mimics preprinted stationery.
By using a <:VARIABLE:> within the image filename, it is also possible to dynamically assign the JPEG or GIF filename at runtime based upon the content of the spooled file page that is being converted. This has a wide variety of applications, such as including a product image based on a product number, or using variations in the company logo that reflect a transaction’s sales region or team. Variables such as <:VARIABLE:> are defined within the CVTSPLPDF parameters EXITPGM(), EXITPGMPRM(), EXITPGMKEY() and EXITPGMPOS().
Example
As an example, the parameters below will create a variable named <:PRODUCTID:> that is populated with the eight characters starting in line 5, column 10 of each spooled file page.
EXITPGM(*VAR) EXITPGMPRM(*POS) EXITPGMPOS((*ALL 5 10 8 PRODUCTID))
The variable <:PRODUCTID:> can now be used within the INCLFILE() parameter to specify an image filename that includes the product id, ensuring that the appropriate product image is added to each PDF page.
INCLFILE(('/product_images/prod_<:PRODUCTID:>.jpg'))
This approach could be useful when converting a product’s Bill of Materials to PDF, as it allows an image of the product to be included in the generated PDF document.
Training Video
For a step by step demonstration of how to use this functionality you can refer to the training video below:
Download CoolSpools FREE for 30 days
Take a free test drive of the entire CoolSpools Suite, including converter, database, email and admin FREE for 30 days.