API referenceRendering & Viewer

pdfRenderAnnotOrField

Render a single annotation's (or field's) widget bounding

C
BOOL32 __stdcall pdfRenderAnnotOrField(PPDF IPDF, uint32_t Handle, BOOL32 IsAnnot, TButtonState State, TCTM* Matrix, TRasterFlags Flags, TPDFPixFormat PixFmt, TCompressionFilter Filter, TPDFBitmap* OutImage);
Delphi
function pdfRenderAnnotOrField(const IPDF: PPDF; Handle: Cardinal; IsAnnot: LongBool; State: TButtonState; var Matrix: TCTM; Flags: TRasterFlags; PixFmt: TPDFPixFormat; Filter: TCompressionFilter; var OutImage: TPDFBitmap): LongBool; stdcall;

Purpose. Render a single annotation's (or field's) widget bounding box to a standalone bitmap, in one of several pixel formats — e.g. for generating a thumbnail/preview of just that annotation rather than the whole page.

Description. Resolves the target's bounding box (D.GetAnnotBBoxH); if valid, renders just that sub-rectangle of the owning page via RenderRegionRGBStruct, else falls back to rendering the whole active page (RenderRegionRGBStruct's -1/full-page path) — i.e. an unresolvable Handle does not fail outright, it silently renders the entire page instead. Unlike pdfRenderPageToImage, PixFmt is genuinely honored here (a real, verified contrast): the RGB24 result is down-converted via RGB24ToGray8/Gray8To1Bit for pxfGray/pxf1Bit, or expanded to RGBA for pxfRGBA (alpha channel handling continues past the excerpt shown). IsAnnot/State select between annotation and form-field widget lookup and, for buttons, which appearance state (/N, /D, /R) to render — the exact dispatch was not traced further in this chapter. Matrix (var TCTM) is declared out/passed by var in the C/Pascal signatures respectively, but this chapter did not confirm it is ever written to by the implementation — treat as read-input CTM unless otherwise verified.

Parameters.

ParameterDescription
IPDFDocument handle.
HandleAnnotation or field handle; if unresolvable, the whole active page renders instead of failing.
IsAnnotSelects annotation vs. form-field lookup for Handle.
StateButton/widget appearance state to render (for field buttons).
MatrixCTM.
FlagsRaster flags (see pdfRenderPage).
PixFmtGenuinely honoredpxfGray/pxf1Bit/pxfRGBA all produce real, format-converted output.
FilterCompression filter for the output (behavior beyond the excerpt not traced in this chapter).
OutImageOutput: Width/Height/Pitch/PixFmt/Data.

Return value. True if a renderable page/region was produced (including the silent whole-page fallback); False if the underlying render call itself fails.

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
[return: MarshalAs(UnmanagedType.Bool)]
Area
Rendering & Viewer
Category

Core

Exported names

pdfRenderAnnotOrField

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.