Four simple utilities convert your spooled files into PDF and archive them.
Portable Document Format (PDF) was designed
by Adobe more than 10 years ago for exchanging documents under Windows, Mac, and
UNIX platforms. Documents are independent from the software and operating system
used to create the files, so a document created in any one of those platforms
looks the same on any of the other platforms. Adobe published the first PDF
specifications in 1993; since then, Adobe has updated the specifications and
made them available for download.
Developers require no licensing to create their own software to read
and create PDF documents for both private and commercial uses. Adobe desires to
promote the use of the PDF not only for information interchange but also as a
preferred standard for electronic archiving.
Nowadays, almost everyone
has downloaded the free Acrobat Reader that allows printing and viewing PDF
documents with magnification, full text search, and other facilities. The file
can be viewed without the originating application, and soon users will be able
to view documents exactly as they were created. In addition, the final document
can be encrypted and password protected from being copied, modified, or printed.
PDF Basics
A standard PDF document is organized into four major parts:
The header identifies the version of the PDF specification to
which the file conforms.
The body is a collection of objects (text
streams, image data, fonts, annotations, etc.) that make up the document
contained in the file.
The cross-reference table contains offsets to
all the objects in the body.
The trailer gives the location of the cross-reference table and of
certain special objects within the body of the file.
All the
specifications in a PDF file are arranged into lines terminated by an
end-of-line(EOL) marker. PDF files with binary data, such as images or
compressed text streams, may have lines of any length, while lines that are not
part of stream object data are limited to no more than 255 characters.
PDF as an Archiving Format for Spooled Files
Now you know how a canonical PDF file is organized.
Because Adobe encourages the use of the PDF for information interchange among
diverse products and applications and gives permission to anyone to prepare
files in which the content conforms to PDF, I now present SCS2PDF, a simple but
complete utility entirely written in RPG that converts iSeries spooled files
into a PDF document. In the second TechTip of this series, I will present an
enhanced version of the same utility that encodes text using the Flate
compression method and reduces the size of the PDF file. In the third TechTip, I
will present another way of converting spooled files into PDF by using the iText
free Java APIs; this utility allows you to add some nice features to your spool
PDF, including custom fonts, logos, and file protection with encryption and
password. While these three utilities can be used for converting and archiving
plain-text reports (SCS spool), in the fourth TechTip, I will show you how to
port the C libTIFF APIs into your iSeries to create graphical PDF documents from
any AFP reports.
The rules described in PDF basics and the sample
provided by Adobe in the PDF specifications are sufficient to write the
following simple utility that converts your spooled files into a well-formed PDF
document. Just consider that this is a simple, general-purpose utility; for a
heavy-duty spool conversion, you may consider a third-party product like IBM
InfoPrint Server (which I'll present in the fourth TechTip). Commercial products
enforce some additional rules for organizing a PDF file to enable efficient
incremental access to a document's components in a network environment. They
also apply techniques to reduce both the size of the file and the amount of
memory and time needed to display pages.
To try this utility, download
the source code and compile as usual. Just remember to create the PF/CPYSPOOL in
QGPL with MAXMBRS(*NOMAX). The SCS2PDF command will quickly generate the PDF
document from your spooled file and store it in a directory in the IFS, ready
for emailing or for accessing via iSeries clients or Web
clients.
TechTip: Spooled Files and PDF, Part One Jul 10 2007 16:53:00
I found the same error in the dicussion list, however my spool file is only a 400 page cobol compile listing. I have only written 21,756 records to cpyspool file. The guy who posted the message below was trying PDF a 20,000 page report... <p>Any ideas: <p>Got an array index error while trying to create a PDF file for a 20,000 plus pages spool file. Following is the part of error message: <p>1181721 records copied to file CPYSPOOL in QGPL. Range of subscript value or character string error. Function check. MCH0603 unmonitored by SCS2PDFR at statement 0000000622, instruction X'0000'. The call to WRITEPAGES ended in error (C G D F).
TechTip: Spooled Files and PDF, Part One Feb 28 2007 09:39:00
I'm having trouble opening the .pdf file, once it has been created. I am using Adobe 5.0. bu when I try to open it I get the error message: "There was an error opening this document. There was a problem reading this document (110)". When I look at the document in Word etc; all the data seems to be there. Could anyone advice a solution - thanks Nigel
TechTip: Spooled Files and PDF, Part One Feb 23 2007 16:25:00
Hi Mr Costagliola; <p>I was able to get the programs to run, and it ran really nice, except when I displayed the pdf, no information was displayed. <p>When I look at the file thru ifs, I can see all the data that was in the spool file. <p>Help <p>Thanks for your help
TechTip: Spooled Files and PDF, Part One Oct 24 2005 10:43:00
Hi Jhspepa, <BR>
I noticed that you are saying that you compiled the programs. <BR>
I'm wondering if you could tell me how you did that, I'm always getting an compilation error. <BR>
I attached the output of the compilation <BR>
CRTBNDRPG PGM(LIBxxx/SCS2PDFD) SRCFILE(LIBxxx/QRPGLESRC) DFTACTGRP <BR>
(*NO) ACTGRP(*NEW) BNDDIR (QC2LE) <BR>
Binding directory object QC2LE in library QSYS specified more than once. <BR>
Definition not found for symbol 'GETCWD'. <BR>
Program SCS2PDFD in library LIBxxx not created. <BR>
Compilation failed. Program SCS2PDFD not created in library LIBxxx. <BR>
Program SCS2PDFD in library LIBxxx not created. <BR>
Compilation failed. Program SCS2PDFD not created in library LIBxxx. <p>Thank you in advance <BR>
Chris
TechTip: Spooled Files and PDF, Part One Apr 13 2005 19:29:00
I have the files on my PC, how do I move them to my QRPGLESRC file?? <BR>
I am an ISeries newbie <p>Thanks in advance <BR>
Paul Stenlund <BR>
Net Admin <BR>
Port of Longview
TechTip: Spooled Files and PDF, Part One Apr 08 2005 10:52:00
I'm having trouble opening the .pdf file, once it has been created. I copied the file to my desktop, but when I try to open it with Adobe Reader 6.0 I get the following error message: <BR>
There was an error opening this document. There was a problem reading this document (110). Does anyone know what the problem might be? <BR>
Thanks, <BR>
Mary
TechTip: Spooled Files and PDF, Part One Mar 10 2005 17:25:00
After installing option 13 (or any other option), you should reload you Cumulative PTF discs. They may contain fixes for that specific option that weren't applied before, because the option didn't exist before. And also check IBM's PTF database, searching on "openness". The PTFs can usually be installed *IMMED, since they're just updating the info in the sample header files.
TechTip: Spooled Files and PDF, Part One Feb 22 2005 11:48:00
Giuseppe, <p>This solved a major problem for me. With another product I was stuck delivering 132 and 198 column reports in 8.5 x 11 PORTRAIT to top managers of the company. I was not happy about that and they were not impressed with my work. <p>After discovering our OS did not have Option 13 installed and fixing that; everything is working wonderfully, and the managers are happy too. <p>Tim Carlo <BR>
Pella, Iowa
TechTip: Spooled Files and PDF, Part One Feb 22 2005 10:06:00
Actually we are using the same technique (outq with dtaq) to produce our account stmts (150,000 each month) but we never had such a problem. Make sure that the program has all the rights to the directory.
TechTip: Spooled Files and PDF, Part One Feb 18 2005 14:59:00
Not knowing JAVA or C I was hoping. Anyway, I have attached a data que to an outque to monitor spoolfile that are sent to it. I'm using your program form a CL to then convert them to PDF, but SCS2PDFR is coming up with the error - Error CrtPDFstmf : unlink() failed. 3029 : Resource busy.. I see in your program where this is generated but don't know what is causing it. <p>Thanks
TechTip: Spooled Files and PDF, Part One Feb 18 2005 12:18:00
The array of locations contains 32000 elements (the maximum allowed) and each spool page takes 4 locations ....... <BR>
Don't forget what I said in the article ".. for heavy-duty purposes you shoul consider buying a 3rd party software like IBM infoPrint..." <p>Btw maybe the utility in part 3 (coming soon) will solve your problem.
TechTip: Spooled Files and PDF, Part One Feb 17 2005 21:47:00
Got an array index error while trying to create a PDF file for a 20,000 plus pages spool file. Following is the part of error message: <p>1181721 records copied to file CPYSPOOL in QGPL. <BR>
Range of subscript value or character string error. <BR>
Function check. MCH0603 unmonitored by SCS2PDFR at statement 0000000622, <BR>
instruction X'0000'. <BR>
The call to WRITEPAGES ended in error (C G D F). <p>Any ideas on how to solve this? <p>If not, what is the limit on the size of the file can be converted to PDF using SCS2PDF command?
TechTip: Spooled Files and PDF, Part One Feb 16 2005 12:45:00
SCS2PDF ends with compression. No more features will be added to this utility. Part 3 and 4 will present 2 more different ways of creating PDFs with Java and C.
TechTip: Spooled Files and PDF, Part One Feb 15 2005 07:52:00
The CDRCVRT CDRA APIs is in library QSYS2. You can also use equivalent APIs (stored in library QSYS) to achieve the same function. The equivalent APIs is QTQCVRT.
TechTip: Spooled Files and PDF, Part One Feb 15 2005 05:43:00
Jody hi, <p>The program is supposed to be in the QSYS2 Library. Do you have such a library ? <BR>
Which release you're working with ? Because we're working with 5.1 and the program attributes say that the earliest release that the program can run is 5.1 <BR>
I can send you a Save file with the program if you're interested. <p>HIH, Moti.
TechTip: Spooled Files and PDF, Part One Feb 11 2005 15:10:00
The program scs2pdfr is blowing up during execution. The following error occurs and I can't figure out what is causing it. <p>Cannot resolve to object CDRCVRT. Type and Subtype X'0201' Authority X'0000'. <p>Thanks, <BR>
Jody
TechTip: Spooled Files and PDF, Part One Feb 08 2005 09:25:00
1. Why do you have to click on a .cmd from windows ? <BR>
2. Even if not used &prop does not produce compile errors <BR>
3. Install 5722SS1 Opt.13 (System Openness Includes)
TechTip: Spooled Files and PDF, Part One Feb 07 2005 18:24:00
Dear Mr Costagliola.. <p>We are very anxious to try a utility like yours but are unable to compile all the programs: <p><li> clicking on the command source takes us to a windows command line<p><li> we had to comment out the " DCL &PROP " statement in the CL source since it was not referrenced<p><li> RPGLE src SCS2PDFR does not compile because we do not have the library QSYSINC for the /copy QYSYINC/QRPGLESRC,QUSEC statement. <p>We are on V5R1. <p>Thank you for whatever help you can provide.
#116973
There are too many comments to list them all here. See the forum for the full discussion.