function SaveAsShadingCreated(Stream: TStream;
const Shadings: TPdfShadingCreateShadings;
out Report: TPdfShadingCreateReport;
AllowSignedDocument: Boolean = False): Boolean; overload;
function SaveAsShadingCreated(const FileName: string;
const Shadings: TPdfShadingCreateShadings;
out Report: TPdfShadingCreateReport;
AllowSignedDocument: Boolean = False): Boolean; overload;
The method stages the current document through PDFium, appends one shading dictionary per Shadings entry with /ShadingType 2 (axial) or 3 (radial), a Device gray/RGB/CMYK, CalGray, CalRGB, Lab or ICCBased colour space, an optional six-element affine /Matrix (when HasMatrix is true), an optional /Background colour array, configurable /Extend flags (when HasExtend is true via ExtendStart and ExtendEnd, defaulting to [true true]), and either a two-stop type-2 exponential blend function (from StartColor/EndColor or a two-entry Stops array) or a Type 3 stitching function over Type 2 segments when Stops supplies 3..256 strictly ordered stops across [0, 1]
Each shading grows the direct or indirect target page /Resources /Shading dictionary under ResourceName (default Sh1, Sh2, ...) and appends one q L B W H re W n [bg re f] [a b c d e f cm] /Name sh Q invocation clipped to either TargetRect (when HasTargetRect is true, also written as /BBox when HasMatrix is false) or the page crop box in a new page content stream, so PDFium's native renderer paints the gradient and any background fill without caller-side rasterisation
Component counts must match the colour space: one value for gray, three for RGB, CalRGB and Lab, four for CMYK, and the profile component count for ICCBased. Optional CalWhitePoint, CalGamma and LabRange entries carry the calibrated colour-space parameters
The result is reopened through strict validation before delivery
/Resources and /Shading dictionaries are resolved; dangling or malformed resource references are rejectedAllowSignedDocument=Truevar
Shadings: TPdfShadingCreateShadings;
Report: TPdfShadingCreateReport;
begin
SetLength(Shadings, 1);
Shadings[0].ShadingType := pstAxial;
Shadings[0].ColorSpace := pscDeviceRGB;
Shadings[0].Coords := nil;
Shadings[0].Coords := TPdfShadingCreateComponents.Create(72, 200, 540, 200);
Shadings[0].StartColor := TPdfShadingCreateComponents.Create(0, 0, 1);
Shadings[0].EndColor := TPdfShadingCreateComponents.Create(1, 1, 1);
Shadings[0].PageNumber := 1;
Pdf1.SaveAsShadingCreated('C:\Gradient.pdf', Shadings, Report);
end;