Optimizing PDF documents



To optimize a PDF document you can reduce the quality of the document. To reduce the quality of a PDF document you can either downsample the images or remove unused objects from the document.

To downsample images the algos attribute is used with values bilinear, bicubic, and nearest_neighbour. The following code snippet generates a PDF after image downsampling:

<cfpdf action = "optimize" algo = "bicubic" source = "..\myBook.pdf" name = #myBook#>

To discard unused objects such as comments, JavaScripts, attachments, bookmarks, and metadata from your PDF document using the following attributes with optimize action:

<cfpdf action = "optimize" 
    noJavaScript 
    noThumbnails 
    noBookmarks 
    noComments 
    noMetadata 
    noFileAttachments 
    noLinks 
    nofonts>

Optimizing page count using encodeall

The new encodeall attribute encodes all the unencoded streams in the source. However, it does not discriminate between dumb encodings like LZW and encodings like flate, so only unencoded streams get flate encoded.

Example:

<cfpdf action=write  source="./inputFiles/Source.pdf" destination="./outputFiles/Output.pdf" encodeAll="yes">