Last Updated on 8 May 2020 by Roberto De Pedrini
This is a collection of FAQs and Howto on print management, PDF production and other things related to prints and IBM i: it wants to be an ever-evolving guide so I also invite you who are reading now to report, via the comments feature , cheats, misgivings and experiences about it.
iPrt-Faq-001: Can I create a PDF from an IBM i spool?
On the market there are excellent tools for managing graphic prints that generally allow you to generate PDF, HTML, XML, XLS etc. and they also manage the flow for real document management.
But even with the tools available to the IBM operating system, you can do good things, both manually and automatically by code.
If we already have a spool in the queue we can open the ACS Access Client Solution print issue management and choose Download or View and Download. The same thing we can do with iNavigator.
If we want to automate the process and generate PDFs in some IFS directory it’s better to work a little bit on the code, let’s see some examples:
- Produce a PDF instead of spooling with OVRPRTF
- Before opening the PrinterFile in our program, it is enough to make an OVRPRTF, for example OVRPRTF(QSYSPRT) DEVTYPE(?AFPDS) WSCT(‘PDF) TOSTMF(‘/home/pdf/invoices/190001.PDF) OVRSCOPE(‘CALLLVL’), then produce the print out in the normal way and at the time of the closing the Printer File we will find the PDF in the specified directory!
- Produce a PDF instead of spooling with an overlay
- If we want to add an Overlay, pretending, to our PDF we can still use OVRPRTF: OVRPRTF(QSYSPRT) DEVTYPE(-AFPDS) WSCT(‘PDF) TOSTMF(‘/home/pdf/invoices/190001.PDF) FRONTOVL(MODFAT 0 0) OVRSCOPE(‘CALLLVL)
- In this case we indicated the MODFAT overlay with offset 0 horizontal and 0 vertical
- Follow the steps below in this guide to create the MODFAT overlay from a PDF or Word template or the one you have on your PC
- From an existing spool to PDF
- In the two cases above we go to produce the PDF instead of the spool … but if we already have the spool in the queue and want to turn it into PDF?
- Let’s use CPYSPLF: CPYSPLF FILE(QPRINT) TOFILE(TOSTMF) JOB(000001/ROBERTO/QPADEV0001) SPLNBR (LAST) TOSTMF(‘/home/pdf/roberto/xx.pdf’) WSCST(‘PDF) STMFOPT(‘REPLACE)
- It is important to correctly locate the print spool by specifying the name of the spool and references to the JOB
- From an existing spool to PDF with pretending overlay
- If, as in the previous case, we already have the spool and we also want to add an overlay… we have to take a few more steps because CPYSPLF does not allow us to do it directly … but with a little cunning:
- CRTPF QTEMP/MYSPOOL RCDLEN(199) MAXMBRS(-NOMAX) SIZE(-NOMAX) LVLCHK(-NO)
- CPYSPLF FILE(ORDINEWEB) TOFILE(QTEMP/MYSPOOL) JOB(037971/ROBERTO/QPADEV0001)SPLNBR(000013) CTLCHAR(-FCFC)
- OVRPRTF FILE(QSYSPRT) DEVTYPE(-AFPDS) CTLCHAR(-FCFC) CHLVAL(-NORMAL) FRONTOVL(ORDITADE) TOSTMF(‘/pdf/2019/orders/1900001.pdf’) WSCST(-PDF)
- CPYF FROMFILE(QTEMP/MYSPOOL) TOFILE(QSYSPRT)
- DLTOVR FILE(QSYSPRT
- As seen in this procedure I create a with a single field of 199 char (198 printing plus one of for control characters such as page jump, line jump), Copy the spool inside the DB file, run an OVRPRTF with the desired overlay module and then print the d file QTEMP … isn’t that great?
Here are some links to learn more about this:
- IBM i forum: Convert spool file with overlay to PDF
- IBM Support: Using CPYSPLF to Re-Create a Spooled File or Create a PC File
- RPGPGM.COM: Creating PDF files from spool files
iPrt-Faq-002: How do you create OVERLAY and PAGE-SEGMENT (AFP Resource)?
The procedure is explained in detail to this link of IBM Support: Creating AFP Resources Using the IBM AFP Printer Drivers
In practice, once you have installed the appropriate AFP drivers downloaded from the RICOH site and properly configured the driver to get Overlay or Page Segment, it is enough to direct our printing of the PDF, Word or what we have for the fining, create a file .prn on your PC, transfer it to IBM i via FTP and generate the CRTOVL overlay object on our system.
I do not explain the process in detail because the IBM Support guide is clear and complete.
iPrt-Faq-003: Can I print a Cariage-return and Line-Feed in a Code128 barcode?
The code128 barcode allows you to create barcodes even with “embedded” a CR-LF for … but in order to “print” these special characters, you have to pay attention to the compilation of the printer file PRTF by specifying the option RPLUNPRT(-NO) in the CRTPRTF:
dcl-s cr char(1) inz(X'0D');
dcl-s lf char(1) inz(X'25');or Dcl-S CRLF char(2) Inz(x'0d25'); ... bcode?%trim(myvar)'cr-lf'%trim(myvar2); ------------------------------ Print file: A BCODE 30A 1 A BARCODE(CODE128 2 -NOHRI (-WIDTH .- A 007))
iPrt-FAQ-004: See spooled files with SQL?
Under the name DB2 for services we find a lot of features and views that allow us to monitor and control system objects … such as print files or print queues:
- QSYS2. OUTPUT_QUEUE_INFO: View of output queues: SE
LECT - FROM QSYS2. OUTPUT_QUEUE_INFO
- QSYS2. OUTPUT_QUEUE_ENTRIES: Spool UDTs
- QSYS2. OUTPUT_QUEUE_ENTRIES: Spool view
- QSYS2. OUTPUT_QUEUE_ENTRIES_BASIC: Simplified spool view
- QSYS2. SPOOLED_FILE_DATA: UDTF for the centenuto of a specific file spool
Example taken from RPGPGM.COM SELECT SIZE,SPOOLNAME,OUTQ,OUTQLIB,CREATED,USER_NAME,STATUS, PAGES,JOB_NAME,FILENUM FROM QSYS2/OUTPUT_QUEUE_ENTRIES ORDER BY SIZE DESC
iPrt-FAQ-005: Is it possible to monitor OUTQ and spools?
Sometimes it can be useful to monitor a specific queue automatically to perform appropriate actions each time a spool file is added to the queue … here’s an old post on IBM System Mag “Automating Spool File Processing” that explains the whole process by creating a special DTAQ and then monitoring the same DTAQ.
iPrt-FAQ-006: Howto view Zebra ZPL preview
If you send ZPL code to your Zebra Label printer maybe you could appreciate this preview service:
iPrt-FAQ-007: Send ASCII chars to EPSON-TM-m30 Printer
You can send ASCII (HEX) chars to a Epson-TM printes with ket TRNSPY keyword:
Here’s an example to cut paper
Ad esempio … il taglio carta a fine scontrino su una stampante EPSON-TM-m30
--- Roberto De Pedrini Faq400.com
A R DK3113E2 A TEXT('CUT RECEIPT') A 1X'1B691B40' A TRNSPY