pdfOptimizer
pdfOptimizer is a Java and .NET add-on for the iText Core PDF library that allows developers to easily optimize PDFs for size or speed, by giving them fine-grained control over various optimization options.
pdfOptimizer provides a wide range of features which include the ability to optimally compress embedded streams within a PDF, to merge duplicate font files and subset fonts to omit unused characters, to convert a document's color space for printing, and so much more. It can also generate a custom report detailing the results of the optimization.
How pdfOptimizer works
Rather than simply converting high-quality images into lower-quality ones using heavy JPEG compression, pdfOptimizer offers various ways to optimize PDFs. You can preserve image quality while achieving the smallest possible file size, convert image types into different file types, resize images, and convert the color space of images from CMYK to RGB. You can also check if the file or image size increased after it is processed, to ensure intelligent use of optimization.
With just few lines of code you can use pdfOptimizer to get great results in no time. This code sample demonstrates an example use case with all the bells and whistles enabled. Click the button in the code window below to switch between the Java and C# examples.
Why use pdfOptimizer?
You can use preset profiles to optimize PDFs, or classes such as FontDuplicationOptimizer
(Java/.NET), CompressionOptimizer
(Java/.NET), and ImageQualityOptimizer
(Java/.NET) for control over specific optimizations.
pdfOptimizer can also check if the file or image size increased after optimization, to ensure compression is used intelligently. So, for instance if you wanted to batch optimize PDFs then you could use pdfOptimizer to automate the process and be certain that you won’t end up with any PDFs that are bigger than the originals.
Use profiles to choose the compression level you want
pdfOptimizer provides preset profiles for developers to use (High, Mid, Low, Lossless, and Custom) for PDF optimization.
Ways to optimize fonts, document structure, and images
Utilize specific classes for font optimization, document structure optimization, or image optimization.
Ideal for batch operations and automation
Since pdfOptimizer includes a size-checking mechanism, it can intelligently check if the file or image size increased after optimization and revert it. Meaning you can be certain that you won’t end up with PDFs that are bigger than the originals.
Core capabilities of pdfOptimizer
pdfOptimizer works by loading a PDF document and performing a set of optimizations to decrease the size of the PDF file. It works just as well for multiple PDFs as for a single document, meaning it’s ideal for automation and batch operations.
Configurable image quality optimization
Since ImageQualityOptimizer
is a configurable class, you can specify image processors for different types of images. You can also optimize images by scaling, not just by simply compressing them.
Supports multiple image types
pdfOptimizer supports JPEG, PNG, TIFF, JBIG2 and JPEG2000 formats.
Extendable scaling algorithm interface
pdfOptimizer provides two different scaling algorithms out of the box, however, you can also provide your own custom implementation using the IScalingAlgorithm
interface.
Skip images you don’t want to optimize
A filter is available to skip images which you don’t want to optimize by providing additional custom requirements with the PdfImageXObjectPredicate
class.
Resources
Here you will find the resources needed to install and use pdfOptimizer.