PDFium Delphi Component Docs

GetObjectRenderedStrokePattern method

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

Syntax

function GetObjectRenderedStrokePattern(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 stroke with a tiling pattern, the native export is missing, or rendering fails

Description

A path object whose stroke colour space is /Pattern with a PatternType 1 (tiling) pattern paints its outline with a repeated cell rather than a flat colour. This method renders that cell on its own through the native FPDFPageObj_GetRenderedStrokePattern 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; the resulting TBitmap belongs to the caller

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

Coloured tiling patterns (PaintType 1) render with their own colours; uncoloured patterns (PaintType 2) render with the stroke colour the content stream selected

Remarks

Example

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

See Also

GetImageObjectRenderedBitmap, GetTextObjectRenderedBitmap, PathInfo, StrokePatternRenderingFeaturesAvailable