Skip to main content Skip to footer

What's New in Document Solutions for PDF v9

v9 - January 6, 2026

New Document Optimization API (Optimize)

The v9.0 release introduces a highly requested enhancement for PDF size reduction and cleanup: a new, unified Optimize() method on the GcPdfDocument class. This API brings together several existing optimization capabilities, such as image deduplication, font handling, stream compression, and object stream usage, into a single, customizable entry point. Developers can now compress and streamline PDFs with one call, significantly improving workflow efficiency and output file size.

Why a Unified Optimize Method?

DsPdf has long included multiple APIs for reducing document size, but developers often needed to combine them manually depending on the scenario. The new optimization pipeline simplifies this process by:

  • Consolidating compression and cleanup operations
  • Providing a single OptimizeDocumentOptions object to configure behaviors
  • Ensuring that optimization and saving happen together (required for options like PdfStreamHandling)
  • Making it easier to script automated processing and bulk PDF optimization workflows

This makes the new Optimize() method ideal for applications involving archiving, uploading, client-side delivery, and server-side document pipelines.

Optimize a PDF in One Line

The DsPdf v9.0 API adds two new overloads:

public void Optimize(Stream stream, OptimizeDocumentOptions options)
public void Optimize(string fileName, OptimizeDocumentOptions options)

Each performs all configured optimizations and then saves the result, ensuring optimizations that affect PDF structure take effect only on save.

Highly Configurable Optimization Options

The new OptimizeDocumentOptions class gives full control over how aggressive or conservative the optimization should be. Developers can fine-tune:

Compression & Stream Behavior
  • CompressionLevel – Overrides the document’s default compression.
  • PdfStreamHandling – Controls how existing streams are rewritten (especially useful for previously loaded PDFs).
  • UseObjectStreams – Enables single or multiple object streams to reduce size significantly.
Font Optimization
  • OptimizeFontsOptions – Shrink embedded fonts and remove unused glyphs.
  • RemoveEmbeddedFonts – Strip all embedded fonts for maximum size reduction (use with caution, as appearance may change).
Image Optimization
  • RemoveDuplicateImages – Consolidates identical image streams to reduce file size.
Document Cleanup
  • DiscardEmbeddedPageThumbnails
  • DiscardOutlines
  • DiscardSubmitImportResetActions
  • DiscardJavaScriptActions
  • DiscardEmbeddedFiles
One-Click Maximum Compression

For scenarios where smallest size is the only priority, such as archival or bandwidth-restricted environments, the SetForMinimumSize() method enables every aggressive optimization, including those not recommended for general use.

Example: Reduce PDF Size While Keeping Content Sharp

var doc = new GcPdfDocument();
using var stream = new FileStream("test.pdf", FileMode.Open);
doc.Load(stream);

var options = new OptimizeDocumentOptions
{
    DiscardEmbeddedPageThumbnails = true
};

doc.Optimize("optimized.pdf", options);

With the new Optimize() method, DsPdf v9.0 makes high-quality, automated PDF optimization easier and more powerful than ever.

Help | Demo