TechTip: Spooled Files and PDF, Part Two

Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

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 email address is being protected from spambots. You need JavaScript enabled to view it..

Giuseppe Costagliola is a programmer in Turin, Italy. You can reach him atThis email address is being protected from spambots. You need JavaScript enabled to view it.

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: