SoftZenPdf.Optimizer 1.1.0

dotnet add package SoftZenPdf.Optimizer --version 1.1.0
                    
NuGet\Install-Package SoftZenPdf.Optimizer -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SoftZenPdf.Optimizer" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SoftZenPdf.Optimizer" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="SoftZenPdf.Optimizer" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SoftZenPdf.Optimizer --version 1.1.0
                    
#r "nuget: SoftZenPdf.Optimizer, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SoftZenPdf.Optimizer@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SoftZenPdf.Optimizer&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=SoftZenPdf.Optimizer&version=1.1.0
                    
Install as a Cake Tool

SoftZenPdf.Optimizer

PDF size optimization for SoftZenPdf, with fine-grained control over what is changed. Each optimization is a handler you add; every object is replaced only when its new version is smaller, and the whole file is kept unchanged when the result would not be smaller.

dotnet add package SoftZenPdf.Optimizer

Requires .NET 8 or later. Brings in SoftZenPdf (the same version). No native libraries.

Optimize a file

using SoftZenPdf.Optimizer;

var optimizer = new PdfOptimizer();
optimizer.AddOptimizationHandler(new CompressionOptimizer());          // recompress streams, object streams
optimizer.AddOptimizationHandler(new DuplicateResourceOptimizer());    // one copy of repeated fonts and images
optimizer.AddOptimizationHandler(new ImageResolutionOptimizer(150));   // downsample images above 225 ppi
optimizer.AddOptimizationHandler(new ImageQualityOptimizer
{
    JpegProcessor = new JpegCompressor(0.75f),
    BitmapProcessor = new BitmapCompressor()
});

var result = optimizer.Optimize("input.pdf", "output.pdf");
Console.WriteLine($"{result.Reduction:P0} smaller");

Handlers

Handler What it does
CompressionOptimizer Recompresses page content, fonts and other streams with Deflate at the strongest setting, and packs objects into compressed object streams (PDF 1.5).
FontDuplicationOptimizer Keeps one copy of fonts embedded more than once, as after merging documents.
DuplicateResourceOptimizer Keeps one copy of any repeated resource: images, forms, fonts, colour spaces and more.
ImageQualityOptimizer Recompresses images with a processor per kind: JpegCompressor(quality) for JPEGs, BitmapCompressor (lossless: palettes, fewer bits, PNG predictors) or BitmapToJpegConverter(quality) (photos to JPEG) for bitmaps.
ImageResolutionOptimizer(ppi) Downsamples images drawn at more pixels per inch than needed, measured from the page content.
ColorSpaceConverter Converts CMYK images to RGB with a device formula (no colour management).

Add handlers in the order they should run: resize, then convert colours, then recompress.

Fast web view

var optimizer = new PdfOptimizer { Linearize = true };
optimizer.AddOptimizationHandler(new CompressionOptimizer());
optimizer.Optimize("report.pdf", "report-web.pdf");

Linearize writes the linearized layout of ISO 32000-1 Annex F, so viewers that load the file over the web show the first page, and jump to any other, before the whole file has downloaded. Encryption and bookmarks are kept. Linearized files use a classic cross-reference table, so object streams are not used.

What you get back

OptimizationResult reports the size before and after, what each handler changed, and every image an image handler looked at: optimized, kept because the result was not smaller, skipped or failed, and why.

Safe by design

  • The output is a complete new file: unused objects and earlier revisions are dropped.
  • Encryption, passwords and permissions of the input are kept.
  • Images are compared by size and only replaced when smaller; lossless processors never change a pixel.
  • PDF/A-1 files keep a classic cross-reference table, and documents with a CMYK output intent keep their CMYK images.
  • Digitally signed files are optimized, with a warning that the signatures no longer validate.

Limits

  • JBIG2 and JPEG 2000 images are not recompressed or resized.
  • CMYK to RGB conversion does not use colour profiles, so colours can look more saturated than in a colour-managed viewer.

Documentation and licensing

Guide: https://pdf.softzensystems.com/docs/guides/optimization
API reference: https://pdf.softzensystems.com/api/

SoftZenPdf.Optimizer is commercial software covered by your SoftZenPdf license, with a free Community license for individuals and organisations under US$1 million annual revenue; see https://pdf.softzensystems.com/pricing. Without a license key, optimized files carry an evaluation mark on every page.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 134 10/2/2026

First release: stream recompression and object streams, font and resource de-duplication, lossless and JPEG image recompression, downsampling to a target resolution, CMYK to RGB conversion and linearization (fast web view), with a per-image report. Full notes: https://pdf.softzensystems.com/changelog