function SaveAsOptionalContentConfigured(Stream: TStream;
const Changes: TPdfOptionalContentStateChanges;
const Options: TPdfOptionalContentConfigureOptions;
out Report: TPdfOptionalContentConfigureReport;
AllowSignedDocument: Boolean = False): Boolean; overload;
function SaveAsOptionalContentConfigured(const FileName: string;
const Changes: TPdfOptionalContentStateChanges;
const Options: TPdfOptionalContentConfigureOptions;
out Report: TPdfOptionalContentConfigureReport;
AllowSignedDocument: Boolean = False): Boolean; overload;
The method stages the current document through PDFium, applies every requested object-number and visibility pair to the selected configuration, appends the smallest required object and cross-reference revision, then reopens the result through strict validation before copying it to the caller's destination
Configuration /ON and /OFF arrays are written for all groups, and existing OCG Usage dictionaries receive an explicit state for Options.Usage because native PDFium rendering gives those values precedence over the configuration arrays
TPdfOptionalContentConfigureOptions.Default selects configuration 0 and View usage, enforces radio groups and removes automatic-state rules which could override the requested result
AllowSignedDocument=True because changing visible content can invalidate signature coverage or policyvar
Changes: TPdfOptionalContentStateChanges;
Options: TPdfOptionalContentConfigureOptions;
Report: TPdfOptionalContentConfigureReport;
begin
SetLength(Changes, 1);
Changes[0].GroupObjectNumber := 12;
Changes[0].Visible := False;
Options := TPdfOptionalContentConfigureOptions.Default;
Pdf1.SaveAsOptionalContentConfigured('C:\Layers.pdf', Changes, Options, Report);
end;