Q: Can Qoppa’s Java PDF library, jPDFProcess, create linearized PDF documents and save existing PDF documents as linearized?

A: Yes, jPDFProcess can create linearize PDF documents.

To linearize a PDF document with jPDFProcess, 2 simple lines of code do the trick:

PDFDocument myPDF= new PDFDocument(“file.pdf);
myPDF.saveDocumentLinearized(new FileOutputStream(“linearizedfile.pdf));

What is PDF linearization and why are PDF documents linearized?

A linearized PDF, also called sometimes “Web Optimized” or “Fast Web View” enabled PDF, is a PDF file that has all the objects ordered in a specific way and with a couple of additional special objects added. The linearized PDF format is completely compatible with the regular pdf format, and a viewer does not need to know anything about linearization to process a linearized PDF .

The purpose of linearization is so that a viewer that does understand the linearization format can display the first page in the document as quickly as possible over a potentially slow network connection and then to subsequently jump to any other individual page requested by the user as quickly as possible, without ever having to download data that is only required for other pages.

A linearized PDF file starts with a linearization dictionary, a cross reference table for all of the first page objects, a special PDF stream object called the hint stream,  and then  all of the objects needed to render the first page. After that all of the objects for all the other pages appear in the file grouped by the page they belong to or, if used by more than one page, in the shared object group. And finally any objects not necessarily needed for page rendering appear followed by a cross reference table for the non-first page objects.

The hint stream is a compact table that can tell a linearization aware viewer which objects are required for any one page, and the file offsets of each of those objects. That way the viewer need only download the first part of the file up to the end of the hint stream, and then send download requests for specific file segments to a web server to be able to display any other page the user may wish to view (e.g. by following a link in the bookmarks, etc.)