/Info dictionaryfunction SaveAsReachable(Stream: TStream; out Report: TPdfPruneReport; AllowSignedDocument: Boolean = False): Boolean;
function SaveAsReachable(const FileName: string; out Report: TPdfPruneReport; AllowSignedDocument: Boolean = False): Boolean;
PDFium first writes a non-incremental copy of the current in-memory document so the rewrite starts from canonical bytes
The object graph is then parsed and a document-wide reachability walk from the catalogue collects every surviving indirect object, including the page tree, page resources, fonts, images, form XObjects, AcroForm, structure tree, outlines, name trees, optional content, metadata, output intents and associated files
Objects left unreachable by incremental updates, page merges, or repaired saves are dropped, and the output is a single classic revision with no object streams and no cross-reference stream
Object numbers and generations are preserved, so every surviving cross-reference stays valid without renumbering; unreachable objects become free entries in the rebuilt classic cross-reference table
The rebuilt trailer carries /Root, /Info and /ID forward only when the referenced objects survived the sweep
TPdfPruneReport reports the kept and pruned indirect object counts, the source and output byte sizes and a structured failure messageAllowSignedDocument is explicitly enabled because a full rewrite invalidates existing signature byte ranges
Pdf.SaveAsReachable('pruned.pdf', Report);
WriteLn('Kept ', Report.KeptObjectCount, ' pruned ', Report.PrunedObjectCount);