PDFium Delphi Component Docs

GetObjectRenderedFillPattern method

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

Syntax

function GetObjectRenderedFillPattern(Index: Integer): TBitmap;

IndexInteger. Zero-based page object index in the range 0 .. ObjectCount - 1
ResultTBitmap. A newly created bitmap the caller owns and must free, or nil when the object does not fill 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 on its own through the native FPDFPageObj_GetRenderedFillPattern export so a caller can inspect, export or preview the pattern without rendering the whole page

The render lock is held for the native call, so it is safe against concurrent rendering on the same component; the native bitmap is converted and destroyed before returning, and 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 an exception; use PageObjectInfo or PathInfo to inspect the object state

Coloured tiling patterns (PaintType 1) render with their own colours; uncoloured patterns (PaintType 2) render with the fill colour the content stream 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