PDFium Delphi Component Docs

SaveAsReachable method

Component: TPdf  ·  Unit: PDFium
Rewrites the document as a single clean revision that keeps only the indirect objects reachable from the catalogue and the trailer /Info dictionary

Syntax

function SaveAsReachable(Stream: TStream; out Report: TPdfPruneReport; AllowSignedDocument: Boolean = False): Boolean;

function SaveAsReachable(const FileName: string; out Report: TPdfPruneReport; AllowSignedDocument: Boolean = False): Boolean;

Description

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

Policies and limits

Example

Pdf.SaveAsReachable('pruned.pdf', Report);
WriteLn('Kept ', Report.KeptObjectCount, ' pruned ', Report.PrunedObjectCount);

See Also

SaveAs, SaveAsRepaired, SaveAsNormalizedContent