Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.
The iQuery.cpytopdf() Stored Procedure copies the specified SPOOLED file to the IFS as a PDF. Effectively the SPOOLED file is converted into a PDF and saved on the IFS.
This function uses the CPYSPLF CL command and all authority and access rights needed for CPYSPLF would be necessary for CPYTOPDF.
iQuery.cpytopdf( pdffile, splfName, splnbr, qualified-job-name )
The pdffile is name of the PDF that will be created on the IFS. For example: '/home/orders/ord12345.pdf'
The SPLFNAME is the name of the SPOLLED file that is to be converted to PDF. This is the SPOOLED File name attribute of the output queue entry.
The SLNBR parameter is the SPOOLED file number. The default is -1 which means *LAST, but may also be 0 to indicate *ONLY. Otherwise, the SPOOLED File Number must be specified.
The JOB is either qualified job name. It defaults to the current job if no value is specified.
call iQuery.cpytoPDF('/home/sales/orderdetails.pdf', 'ORDER');
In this example, the PDF file named OrderDetails.PDF is created from the SPOOLED file named ORDER that is the last SPLNBR (SPOOLED File Number) with that name. It looks for the SPOOLED file in the current job; that is the job calling the CPYTOPDF Stored Procedure.