pdfReadImageResolution
Read the embedded DPI (dots-per-inch) resolution metadata of
BOOL32 __stdcall pdfReadImageResolutionA(PPDF IPDF, const char* FileName, uint32_t Index, uint32_t* ResX, uint32_t* ResY);
BOOL32 __stdcall pdfReadImageResolutionW(PPDF IPDF, const wchar_t* FileName, uint32_t Index, uint32_t* ResX, uint32_t* ResY);
BOOL32 __stdcall pdfReadImageResolutionEx(PPDF IPDF, void* Buffer, uint32_t BufSize, uint32_t Index, uint32_t* ResX, uint32_t* ResY);
function pdfReadImageResolutionA(const IPDF: PPDF; const FileName: PAnsiChar; Index: Cardinal; var ResX, ResY: Cardinal): LongBool; stdcall;
function pdfReadImageResolutionW(const IPDF: PPDF; const FileName: PWideChar; Index: Cardinal; var ResX, ResY: Cardinal): LongBool; stdcall;
function pdfReadImageResolutionEx(const IPDF: PPDF; Buffer: Pointer; BufSize: Cardinal; Index: Cardinal; var ResX, ResY: Cardinal): LongBool; stdcall;
Purpose. Read the embedded DPI (dots-per-inch) resolution metadata of an external image file/buffer, without loading it into the document.
Description. Both ResX/ResY are pre-seeded to 72 (the PDF/print default) before parsing begins, so a format lacking DPI metadata (or a parse failure past the initial file-existence/buffer-non-empty check) still leaves the output at a sane default rather than 0. A/W read the whole file first; Ex parses the caller's buffer directly. Index is accepted by all three but not documented as reaching the underlying ApiReadImageDPI parser with any per-frame effect beyond whatever that parser's own multi-frame handling does internally — treat multi-frame (e.g. multi-page TIFF) DPI reading as returning the first frame's resolution regardless of Index, consistent with this chapter's other Index-ignoring insertion functions (Image Insertion and Replacement).
Parameters.
| Parameter | Description |
|---|---|
IPDF | Accepted but not consulted for document state (pure file/buffer parse). |
FileName / Buffer,BufSize | The image to inspect. |
Index | Frame index — not verified to have any effect; treat as always reading the first frame. |
ResX, ResY | Output: DPI values, pre-seeded to 72 before parsing. |
Return value. True if the file/buffer was read and DPI metadata parsed; False if the file doesn't exist / buffer is empty, or ResX/ ResY is a null pointer.
C# (P/Invoke)
[return: MarshalAs(UnmanagedType.Bool)]
Core
pdfReadImageResolution
pdfReadImageResolutionA
pdfReadImageResolutionW
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.