API reference › Rendering & Viewer
pdfRenderAnnotOrField
Render a single annotation's (or field's) widget bounding
BOOL32 __stdcall pdfRenderAnnotOrField(PPDF IPDF, uint32_t Handle, BOOL32 IsAnnot, TButtonState State, TCTM* Matrix, TRasterFlags Flags, TPDFPixFormat PixFmt, TCompressionFilter Filter, TPDFBitmap* OutImage);
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.
| Parameter | Description |
|---|---|
IPDF | Document handle. |
Handle | Annotation or field handle; if unresolvable, the whole active page renders instead of failing. |
IsAnnot | Selects annotation vs. form-field lookup for Handle. |
State | Button/widget appearance state to render (for field buttons). |
Matrix | CTM. |
Flags | Raster flags (see pdfRenderPage). |
PixFmt | Genuinely honored — pxfGray/pxf1Bit/pxfRGBA all produce real, format-converted output. |
Filter | Compression filter for the output (behavior beyond the excerpt not traced in this chapter). |
OutImage | Output: 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)
[return: MarshalAs(UnmanagedType.Bool)]
Core
pdfRenderAnnotOrField
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.