Hi Lori,
The easiest way is if you have a printer file. Below is one of my CRTPRTF. Notice DEVTYPE, TOSTMF, WSCST.
CRTPRTF FILE(objlib-name/prtf-name)
SRCFILE(srclib-name/QDDSSRC)
SRCMBR(prtf-name)
DEVTYPE(*AFPDS)
PAGESIZE(8.5 11 *UOM)
LPI(8)
CPI(16.7)
FRONTMGN(0.5 0.5)
OVRFLW(55)
UOM(*INCH)
TOSTMF('/path/Name of report goes here.PDF')
WSCST(*PDF)
REPLACE(*YES)
If the printer file will be used for both printing and creating PDFs then you can use OVRPRTF at run time with the same parameters.
If you want to convert an existing spooled file to a PDF, you can use SQL:
SELECT job_name,
spooled_file_name,
file_number,
systools.generate_pdf(
job_name => job_name,
spooled_file_name => spooled_file_name,
spooled_file_number => file_number,
path_name => '/home/GLENN/' CONCAT REGEXP_REPLACE(job_name, '/', '_') CONCAT '_' CONCAT spooled_file_name CONCAT '_'
CONCAT file_number) AS "PDF Created?",
'/home/GLENN/' CONCAT REGEXP_REPLACE(job_name, '/', '_') CONCAT '_' CONCAT spooled_file_name CONCAT '_' CONCAT file_number
CONCAT '.pdf' AS pdf_path
FROM qsys2.output_queue_entries_basic
WHERE job_name = '942614/COMPOPR/ETHA11'
AND spooled_file_name = 'QPJOBLOG';
-- Alternate method.
VALUES
SYSTOOLS.GENERATE_PDF(
JOB_NAME => '942614/COMPOPR/ETHA11',
SPOOLED_FILE_NAME => 'QPJOBLOG',
SPOOLED_FILE_NUMBER => 77,
PATH_NAME => '/home/GLENN/942614_COMPOPR_ETHA11_QPJOBLOG_77');
There are lots of good articles:
https://gist.github.com/forstie/3805d74a06d3349a00deef704e40b219https://gist.githubusercontent.com/forstie/3805d74a06d3349a00deef704e40b219/raw/32d4943aeecd87deef9cd0cf9feac78fe66e51f8/generate%2520pdf.sqlhttps://www.ibm.com/docs/en/i/7.3?topic=services-generate-pdf-scalar-functionLastly, there is the old method of using CPYSPLF:
CPYSPLF FILE(QPJOBLOG)
TOFILE(*TOSTMF)
JOB(942614/COMPOPR/ETHA11)
SPLNBR(*LAST)
TOSTMF('/HOME/GLENN/942614_COMPOPR_ETHA11_QPJOBLOG_77.PDF')
WSCST(*PDF)
STMFOPT(*REPLACE)
------------------------------
Glenn Gundermann
Glenn Gundermann
Thornhill ON
(416) 317-3144
------------------------------
Original Message:
Sent: Wed February 23, 2022 09:40 AM
From: Lori Austin
Subject: Generating Reports to PDF
I am fairly new to IBMi. I switched over from Visual Foxpro (I know that is still old school) where we had a very easy to use wysiwyg report generator to print reports or save to PDF. My shop previously used printer files then converted to PDF. I know RDi has an option but it is not very intuitive.
We are currently passing the data to node.js programs that generate a pdf, but it is taking my team days or weeks to program reports that would have taken me just hours with my old Foxpro tool. What am I missing? There must be some report generating tool for IBM i that I am not aware of.
------------------------------
Lori Austin
------------------------------