int32_t __stdcall pdfSaveImageToFileA(PPDF IPDF, const char* FileName);
int32_t __stdcall pdfSaveImageToFileW(PPDF IPDF, const wchar_t* FileName);
const char* __stdcall pdfSaveImageToString(PPDF IPDF);
function pdfSaveImageToFileA(const IPDF: PPDF; FileName: PAnsiChar): Integer; stdcall;
function pdfSaveImageToFileW(const IPDF: PPDF; FileName: PWideChar): Integer; stdcall;
function pdfSaveImageToString(const IPDF: PPDF): PAnsiChar; stdcall;
Purpose. Write the currently selected image's (via pdfSelectImage, Image Objects and Introspection) raw bytes to a file, or return them as an in-memory buffer.
Description. Both resolve the target image through SelectedImageH - 1 — not FImageCount - 1 like pdfGetImageBuffer above. pdfSaveImageToFile writes the image's original encoded bytes verbatim to FileName. pdfSaveImageToString copies the same bytes into a document-owned transient buffer (GapRetA, overwritten on next use) and returns a pointer to it. Both fail if no image is currently selected (pdfSelectImage was never called, or was cleared with ImageID=0).
Parameters.
| Parameter | Description |
|---|---|
IPDF | Document handle. |
FileName | *(SaveToFile only)* Output file path. |
Return value. pdfSaveImageToFile: 1 on success, 0 if no image is selected or the write failed. pdfSaveImageToString: pointer to the byte buffer, or nil if no image is selected.
See also. pdfSelectImage, pdfGetImageBuffer (the last-inserted-image counterpart — a different target).
C# (P/Invoke)
public static extern int pdfSaveImageToFileW(IntPtr IPDF, IntPtr FileName);
public static extern int pdfSaveImageToFile(IntPtr IPDF, IntPtr FileName);
public static extern int pdfSaveImageToFileA(IntPtr IPDF, IntPtr FileName);
Core
pdfSaveImageToFileW
pdfSaveImageToFile
pdfSaveImageToFileA
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.