PDF Optimization

Many PDFs are designed for high-quality print output and are not optimized for the web. PDF files are based on PostScript and contain binary data. PDFs use LZW, JPEG, Flate (ZIP), CCITT (the facsimile standard, Group 3 or 4), run-length, and JBIG2 compression (in PDF version 1.4). The last four are used for monochrome images. Like other multimedia formats, optimizing PDFs takes a two-step approach: creating the compound document, and saving it.

Creating Small PDFs

The main factors that increase the size of PDFs are image resolution, image type (bitmapped or vector), and PDF version. To create the smallest possible PDFs for the web, minimize the number embedded images and fonts, substitute vector-based graphics where possible, and capture and prepare the images you include for maximum compressibility. See Chapter 12, "Optimizing Web Graphics," for more information on preparing compressible images.

For graphics that must be inserted as bitmapped images, use the best-quality images that you can at the output resolution of the PDF. This way, Acrobat Distiller compresses them only once, rather than resampling and recompressing images. Inserting compressed JPEGs within PDFs and recompressing them in Distiller can create noticeable artifacts.

Use vector-based graphics when possible for images that you would make into GIFs. Vector images are compact, scale perfectly , and look great at any resolution, even when printed. You also can compress vector image data in your PDF using ZIP compression, which is built into the PDF format. Acrobat Reader version 4 and higher also supports SVG.

Minimize the number of fonts that you use in your PDFs, or use one of the 14 built-in "base" fonts for maximum download speed.

Dynamic PDF Creation

You can create PDFs on the fly in a number of ways. Both open source and commercial products are available. For XML source files, you can use the Formatting Objects Processor (FOP) from Apache (http://xml.apache.org/fop/). FOP generates PDFs page by page, so it does basic page optimization and supports PDF version 1.3 (Acrobat 4). Another open source tool in Java is iText (http://www.lowagie.com/iText/); this tool con verts XML directly into PDF documents and compresses for size but does not linearize.

Many commercial products including PDFLib (www. pdflib .com) enable you to create PDF documents on many platforms, including Windows with ASP and ASP.NET.

Saving PDFs

In Acrobat (the full version) or Distiller, you can reduce the resolution of bitmapped images to a fixed value and use JPEG or ZIP compression. Set the resolution to "screen" (72 dpi) to create the smallest files or "eBook" (150 to 300 dpi) for laptops and mobile devices (see Figure 13.10).

Figure 13.10. Distiller downsamples images to 150 and 300 dpi in eBook mode.
graphics/13fig10.gif

Adobe recommends using the default of eBook over the screen option, although eBook files are larger. Double-check your images for legibility after using the screen setting because they can become blurry. Table 13.2 compares various Distiller settings on a sample file with a number of images:

Table 13.2. Acrobat Distiller Output Setting versus File Size
  PostScript Screen eBook Print Press
File size 12.3MB 397KB 1.6MB 3.0MB 3.4MB
Image resolution N/A 72 dpi 150 to 300 dpi 300 to 1200 dpi 2400 dpi

The text itself also can be compressed using ZIP compression in Distiller. Always subset your embedded fonts for the web. Font subsets contain only the glyph descriptions that are actually used in your document. If you don't subset your fonts, the entire font will be included in the PDF document, which can easily add 40KB per font to the file.

To minimize file size, turn off thumbnails when saving PDFs for the web.

For PDF files, the higher the version the smaller the file. Adobe has made Acrobat more efficient with each revision. Of course, using the latest PDF version will create compact files but require that your users have the latest plug-in.

Avoiding Fat Forms

In Acrobat 4, forms can become very large. Acrobat 5 forms are much smaller. For minimum size in Acrobat 5, you can use JavaScript to place the objects in the page. To use this feature, select Document > Set Page Action and select JavaScript from the Action types, and then press the Edit button and enter the JavaScript. See the JavaScript documentation in the Help menu for more details. The disadvantage of this form creation method is that the output is compatible only with Acrobat 5.

Optimizing PDF Files

Even after you've created your PDF, you must optimize the file for the web. Optimizing PDF documents does the following:

  • Removes duplicate objects

  • Removes old and unneeded versions of objects

  • Linearizes the output per page

The result is a compact, linearized PDF that displays the first page (or an arbitrary page) quickly, while the rest of the file downloads. Although linearized PDFs are slightly larger, they also increase perceived speed.

One easy way to trim your PDF file is to Save As to a new file in Acrobat. This removes unnecessary objects automatically. Finally, use the Acrobat's PDF Consultant (select Tools > PDF Consultant) to analyze and remove elements, and select "Optimize Space"(select Tools > PDF Consultant > Optimize Space) to minimize file size.

Further Reading

For more information about PDF optimization, see these resources:

  • Adobe Acrobat 5 Master Class (Adobe Press, 2002)The best book on advanced Acrobat. Also includes a "Managing File Size" section on optimizing the size of PDF files.

  • PDFzone (http://www.pdfzone.com/)Devoted exclusively to PDFs and professionals.

  • Planet PDF (http://www.planetpdf.com/)All PDFs, all the time.

  • For PDF optimization products, see this book's companion web site (http://www.WebSiteOptimization.com).

 



Speed Up Your Site[c] Web Site Optimization
Speed Up Your Site[c] Web Site Optimization
ISBN: 596515081
EAN: N/A
Year: 2005
Pages: 135

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net