PeachPDF

PeachPDF.PeachPdfDocument

PeachPdfDocument.ConsolidateImages() Method

Merges embedded raster images that encode to byte-identical PDF image objects, keeping one copy and repointing every other reference at it. Call this after all pages have been added, and before Save(Stream) - a page’s resources are rewritten in place, but the size reduction only takes effect once Save(Stream) drops the now-unreferenced duplicate objects.

public void ConsolidateImages();

Remarks

Repeated references to the <em>same</em> resolved image source within one PdfGenerator.GeneratePdf/AddPdfPages call already share one decoded, embedded image automatically - see PdfGenerator. This method is for what that doesn’t cover: images added across separate AddPdfPages/AddPages calls into the same document, or two different sources that happen to encode identical bytes. It isn’t run automatically, since hashing every embedded image isn’t a cost most documents should pay on every Save(Stream).