pdfGetPrintPreviewBitmapToString
Render a page to a real 24-bit BMP thumbnail, aspect-fit
const char* __stdcall pdfGetPrintPreviewBitmapToStringA(PPDF IPDF, const char* PrinterName, int32_t PreviewPage, int32_t PrintOptions, int32_t MaxDimension, int32_t PreviewOptions);
function pdfGetPrintPreviewBitmapToStringA(const IPDF: PPDF; PrinterName: PAnsiChar; PreviewPage, PrintOptions, MaxDimension, PreviewOptions: Integer): PAnsiChar; stdcall;
Purpose. Render a page to a real 24-bit BMP thumbnail, aspect-fit within MaxDimension, returned as a raw byte buffer (a "string" containing actual binary BMP bytes, not a filename or a base64/text encoding) — for building a print-preview thumbnail panel.
Description. Genuinely real: renders the requested page's content (RenderPageToRGB via the shared BuildRenderResources pipeline — the same real renderer used by V15's pdfRenderPageToImage), then packs a proper DWORD-aligned bottom-up 24-bit BMP file (including a correct 54-byte BITMAPFILEHEADER+BITMAPINFOHEADER) directly into the shared ANSI result buffer. Ignored parameters: pdfGetPrintPreviewBitmapToStringA and ...W both call the exact same internal PreviewBmp(IPDF, PreviewPage, MaxDimension) helper — PrinterName, PrintOptions, and PreviewOptions are all accepted by the ABI but none of the three reaches the real function at all. Despite PrinterName strongly implying the preview should reflect a specific printer's real paper size/margins/DPI (the whole point of a "print preview" as opposed to a generic page thumbnail), the generated bitmap is always just a generic page-aspect-ratio thumbnail, identical regardless of which printer name (if any) is passed. MaxDimension defaults to 150 if ≤ 0.
Parameters.
| Parameter | Description |
|---|---|
IPDF | Document handle. |
PrinterName | Accepted but never used — the preview never reflects any specific printer's paper size/margins. |
PreviewPage | 0-based page index to render. |
PrintOptions, PreviewOptions | Both accepted but never used. |
MaxDimension | The longer side's target pixel size (defaults to 150 if ≤ 0); the shorter side is scaled to preserve aspect ratio. |
Return value. A raw BMP byte buffer (transient, in the shared ANSI result buffer — pdfAnsiStringResultLength, Output Intents, Rich Media/SVG/SWF Annotations, File Attachments, and Misc, reports its exact byte length); nil if the page index or size can't be resolved.
C# (P/Invoke)
public static extern IntPtr pdfGetPrintPreviewBitmapToStringW(IntPtr IPDF, IntPtr PrinterName, int PreviewPage, int PrintOptions, int MaxDimension, int PreviewOptions);
public static extern IntPtr pdfGetPrintPreviewBitmapToString(IntPtr IPDF, IntPtr PrinterName, int PreviewPage, int PrintOptions, int MaxDimension, int PreviewOptions);
public static extern IntPtr pdfGetPrintPreviewBitmapToStringA(IntPtr IPDF, IntPtr PrinterName, int PreviewPage, int PrintOptions, int MaxDimension, int PreviewOptions);
Getters
pdfGetPrintPreviewBitmapToStringW
pdfGetPrintPreviewBitmapToString
pdfGetPrintPreviewBitmapToStringA
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.