TechTip: Spooled Files and PDF, Part One

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

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.

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: