PDFium Delphi Component Docs

GetObjectRenderedFillPattern method

Component: TPdf  ·  Unit: PDFium
Rasterises the tiling pattern with which a page object is filled and returns it as a caller-owned bitmap

Syntax

function GetObjectRenderedFillPattern(Index: Integer): TBitmap;

IndexInteger. Zero-based page object index within the range 0 .. ObjectCount - 1
ResultTBitmap. A newly created bitmap owned by the caller, who must free it, or nil when the object is not filled with a tiling pattern, the native export is missing, or rendering fails

Description

A path object whose fill colour space is /Pattern with a PatternType 1 (tiling) pattern paints its interior with a repeated cell rather than a flat colour. This method renders that cell in isolation through the native FPDFPageObj_GetRenderedFillPattern export, so a caller can inspect, export or preview the pattern without rendering the entire page

The render lock is held for the duration of the native call, so the method is safe against concurrent rendering on the same component. The native bitmap is converted and destroyed before the method returns; the resulting TBitmap belongs to the caller

The call requires the current page to be active. Objects that are not paths, paths filled with a plain colour or a shading pattern, and stroke-only patterns all yield nil rather than raising an exception; use PageObjectInfo or PathInfo to find out why

Coloured tiling patterns (PaintType 1) render using their own colours; uncoloured patterns (PaintType 2) render using whatever fill colour the content stream has selected

Remarks

Example

var
  I: Integer;
  Bmp: TBitmap;
begin
  for I := 0 to Pdf1.ObjectCount - 1 do
  begin
    Bmp := Pdf1.GetObjectRenderedFillPattern(I);
    if Bmp <> nil then
      try
        Bmp.SaveToFile(Format('fill-pattern-%d.bmp', [I]));
      finally
        Bmp.Free;
      end;
  end;
end;

See Also

GetObjectRenderedStrokePattern, GetImageObjectRenderedBitmap, GetTextObjectRenderedBitmap, PathInfo, FillPatternRenderingFeaturesAvailable