TechTip: Spooled Files and PDF, Part Two PDF Print E-mail
Written by Giuseppe Costagliola   
Thursday, 03 February 2005

Now, let's talk about compression.

In Part One of this series, I presented a simple utility to convert your spooled files into PDF. Maybe you used a text editor to open a PDF document created with the utility and you saw that the iSeries spool was written to PDF in clear text, line by line. However, PDF includes the ability to reduce the file size by using a filter to compress all data streams. This operation can occur on the streams before they are put into the PDF document and then be applied from Acrobat Reader while processing the stream for the input PDF.

The PDF Filters

When you generate a new PDF file, you can compress text streams using a method that PDF supports as a standard filter. For each stream that has been compressed, the generated PDF object includes the /Filter key followed by the compression method used: For text data, we can use Lempel-Ziv-Walsh (LZW) and Flate filters.

LZWEncode and LZWDecode are filters for encoding and decoding data according to the LZW compression scheme (United States patent number 4558302, owned by the Unisys Corporation), and you must get a regular license to develop software using LZW.

FlateEncode and FlateDecode Filters, however, are based on the public domain zlib/deflate compression method (also called zip, the same algorithm used in popular PC applications like PKZIP or WinZip). But in order to create a compressed stream, you do not need to create a zipped file: You just use the compress algorithm from zlib as written by Jean-loup Gailly. You can either download the entire zlib source code from the zlib home page or just use the code that accompanies this article because, as I just said, you don't use the entire zlib library.

Upgrade the SCS2PDF Utility with Flate Compression

Before you try this version of the utility, you have to perform some preliminary steps to compile the new SCS2PDFR program.

In your iSeries, first create a source file called QSCS2PDF. Then, with iSeries Navigator, create a folder called pdf and some subdirectories, as in Figure 1.

http://www.mcpressonline.com/articles/images/2002/PDF2V3--02040501.png

Figure 1: Create the required subdirectories. (Click images to enlarge.)

Now, you can download the utility and move the RPGLE and REXX sources into the QSCS2PDF and all the .c and .h sources into the respective IFS subdirectories you created. The sources of other modules (CMD and CLLE) are unchanged from Part One of this series.

You can create the new SCS2PDFR program that includes the C compress modules from zlib by running the MAKE REXX procedure (you can use PDM option 16). After this, you are ready to run the SCS2PDF command and see how the final PDF file can be reduced in size with the Flate compression utility.

In the next TechTip in this series, I will present a different and more sophisticated implementation of this utility. That one interfaces with the powerful Java iText APIs that allow you to create PDF documents from spooled files with custom fonts, company logo, encryption, and more. Stay tuned!

Giuseppe Costagliola is a programmer in Turin, Italy. You can reach him at This e-mail address is being protected from spam bots, you need JavaScript enabled to view it .


Last Updated ( Thursday, 03 February 2005 )
 
Discuss (13 posts)
Guest.Visitor
TechTip: Spooled Files and PDF, Part Two
Jun 04 2007 09:58:00
Please email me your solutions as well. I am very grateful for your assistance. <p>Walt Bennett <BR> wbennettjr@yahoo.com
#117443
asulin_sh
TechTip: Spooled Files and PDF, Part Two
Apr 01 2005 07:17:00
Hi Moti! <p>Have you found the way how to translate Hebrew ? <BR>
I well tank you if you send me the solution. <p>Thanks
#117442
gcostagliola@tin.it
TechTip: Spooled Files and PDF, Part Two
Feb 18 2005 05:49:00
Btw if you want to get a better highlight effect you can try <p>BuildStream('0.05 0.15 TD'+LF:13); <p>instead of <p>BuildStream('0 0 TD'+LF:7);
#117441
gcostagliola@tin.it
TechTip: Spooled Files and PDF, Part Two
Feb 17 2005 05:59:00
If you have a lot of overprinting, the STREAM buffer cannot be large enough and the program crashes. To fix this you can enlarge some fields as in the code section. <p><!--mccodelink_begin--> <BR>
<!-- do not remove --> <BR>
<hr width=50 align=left><small><a href='http://www.mcpressonline.com/mc/showcode@@.6b218aea/9' target='_blank'>Code</a></small> <BR>
<!--mccodelink_end-->
#117440
Guest.Visitor
TechTip: Spooled Files and PDF, Part Two
Feb 16 2005 06:12:00
Hi Mr peterkin9 <p>Our company is still running on V4R4 and probably will not upgrade until the AS400 have serious problem. I would appreciate if you could email me your RPG IV fixed format version of the program as I was unable to program in RPG free format. <p>Thanks and regards <BR>
Araman <BR>
(araman@jvm.com.my) <BR>
(araman_amru@yahoo.com)
#117439
Guest.Visitor
TechTip: Spooled Files and PDF, Part Two
Feb 14 2005 09:04:00
I have managed to convert the two programs to a version of RPGIV which will run at v4.4 The main obstacles were the lack of %TIME and %DATE Built In Functions and the inability to specify which member of CPYSPOOL would be opened. For the first two, I used the TIME Operation Code and rather than use the DoCmd to do an OVRDBF, I did this within the CL program. <BR>
If anyone is in a similar position, I would be pleased to email the necessary code. <p>Peter Kinsman
#117438
motis
TechTip: Spooled Files and PDF, Part Two
Feb 10 2005 14:22:00
Giuseppe hi, <BR>
Thank you very much. All it needed was to add the QC2LE in the CRTPGM. It may not be needed at v5r2 but I still am at the v5r1 level. <BR>
Anyway it works now. <BR>
All I need now is for you to release Part Three and maybe there I'll find some way to be able to translate the Hebrew alphabet. <BR>
Thank you very much again, <BR>
Moti.
#117437
Guest.Visitor
TechTip: Spooled Files and PDF, Part Two
Feb 09 2005 13:11:00
I have the new version up and running. Thanks for including the code to handle overprinting and enlarging the output file size.
#117436
gcostagliola@tin.it
TechTip: Spooled Files and PDF, Part Two
Feb 08 2005 05:08:00
Make sure you compiled with the enclosed REXX procedure. Try to add the QC2LE in the CRTPGM (that seems unnecessary at v5r2): <p><!--mccodelink_begin--> <BR>
<!-- do not remove --> <BR>
<hr width=50 align=left><small><a href='http://www.mcpressonline.com/mc/showcode@@.6b218aea/4' target='_blank'>Code</a></small> <BR>
<!--mccodelink_end-->
#117435
motis
TechTip: Spooled Files and PDF, Part Two
Feb 07 2005 07:07:00
Giuseppe hi, <BR>
I tried to compile the SCS2PDFR's new version but the compile failed. <BR>
I followed your instructions in creating the relevant directories in the IFS and downloading the 'c' and 'h' sources accordingly. <BR>
After making the relevant changes for release 5.1, it failed to compile and displayed the following statements (see code below). <BR>
Can you help ? <BR>
Moti. <p><!--mccodelink_begin--> <BR>
<!-- do not remove --> <BR>
<hr width=50 align=left><small><a href='http://www.mcpressonline.com/mc/showcode@@.6b218aea/2' target='_blank'>Code</a></small> <BR>
<!--mccodelink_end-->
#117434
gcostagliola@tin.it
TechTip: Spooled Files and PDF, Part Two
Feb 06 2005 16:28:00
I think that if you rewrite the code in fixed format, it should work as well. The C compression will work too, but maybe you don't have the compiler because it bacame free starting from V5R1. But you can try to get the C modules compiled in a V5 for previous release and link them with the RPG, then create the final program.
#117433
Guest.Visitor
TechTip: Spooled Files and PDF, Part Two
Feb 04 2005 07:05:00
For some reason I did not look at Part 1 of this article when it was originally sent, but I now realize that it will achieve something I was discussing with a client only yesterday. Except that for a number of reasons we are both still running version 4.4, which cannot understand many of the latest RPGLE changes. One solution would be to upgrade, but on 150 that would mean a more powerful box. Another would be to convert the programs to fixed format ILE RPG. I have other clients on version 4.5 so I could compile there, but does anyone know if the programs use functions that would not be avaliable if I set the target release to V4R4M0? <p>Must get out of this time warp one day! <p>Many thanks <p>Peter Kinsman
#117432
MC Press Web Site Staff
TechTip: Spooled Files and PDF, Part Two
Jun 04 2007 09:58:00
This is a discussion about <B>TechTip: Spooled Files and PDF, Part Two</b>.<p align='center'><a href=http://www.mcpressonline.com/mc?1@232.1KNKfHX1eQT.17@.6b2171ed>Click here for the article</a>.</p>
#117431


Discuss...
User Rating: / 1
PoorBest 
Related Articles
< Prev   Next >

   MC-STORE.COM