BI/ID/EI inline image into a reusable image XObject and replacing each inline block with a /ImN Do operatorfunction SaveAsInlineImagesExternalised(Stream: TStream; const Options: TPdfInlineImageExternaliseOptions; out Report: TPdfInlineImageExternaliseReport; AllowSignedDocument: Boolean = False): Boolean;
function SaveAsInlineImagesExternalised(const FileName: string; const Options: TPdfInlineImageExternaliseOptions; out Report: TPdfInlineImageExternaliseReport; AllowSignedDocument: Boolean = False): Boolean;
Each page content stream is decoded and scanned for inline images; every BI/ID/EI block is extracted into a new image XObject indirect object
Inline-image dictionary abbreviations (/W, /H, /BPC, /CS, /F, colour-space and filter value abbreviations) are expanded to their full image-XObject names so the extracted object is standards-compliant
The inline block in the content stream is replaced by /ImN Do, the page /Resources /XObject dictionary is updated with the new reference, and the rewritten content stream is Flate-compressed
Object numbers and generations of existing objects stay stable; new image XObjects and content streams are appended
TPdfInlineImageExternaliseOptions.SkipUnsafePages leaves pages whose inline-image boundaries cannot be determined unchanged rather than aborting the saveTPdfInlineImageExternaliseReport reports externalised, skipped and failed counts plus the created XObject count/Resources or unresolvable content are skippedAllowSignedDocument is explicitly enabled because a full rewrite invalidates existing signature byte ranges
Options.SkipUnsafePages:= True;
Pdf.SaveAsInlineImagesExternalised('externalised.pdf', Options, Report);
WriteLn('externalised ', Report.ExternalisedCount, ' inline images');