pdfGetAnnotSoundToFile
Extract a legacy Sound annotation's embedded audio bytes
int32_t __stdcall pdfGetAnnotSoundToFileA(PPDF IPDF, int32_t Index, int32_t Options, const char* SoundFileName);
int32_t __stdcall pdfGetAnnotSoundToFileW(PPDF IPDF, int32_t Index, int32_t Options, const wchar_t* SoundFileName);
const char* __stdcall pdfGetAnnotSoundToString(PPDF IPDF, int32_t Index, int32_t Options);
function pdfGetAnnotSoundToFileA(const IPDF: PPDF; Index, Options: Integer; SoundFileName: PAnsiChar): Integer; stdcall;
function pdfGetAnnotSoundToFileW(const IPDF: PPDF; Index, Options: Integer; SoundFileName: PWideChar): Integer; stdcall;
function pdfGetAnnotSoundToString(const IPDF: PPDF; Index, Options: Integer): PAnsiChar; stdcall;
Purpose. Extract a legacy Sound annotation's embedded audio bytes (/Sound stream) to a file or an in-memory buffer.
Description. Options is accepted by all three but never consulted — the same dropped-parameter pattern seen elsewhere in this manual (e.g. pdfSaveImageListItemDataToFile's Options, Image Buffers, Resolution, Cache, and OCR); the raw sound stream bytes are always extracted verbatim regardless of what Options specifies. Index addresses the sound annotation by its position (semantics tied to GetAnnotSoundBytes's own indexing — not independently re-verified in this chapter as document-wide-handle-based vs. a dedicated sound-annotation-only index; treat Index as a sound-annotation-specific ordinal rather than the general FAnnotByHandle handle space used elsewhere in this volume).
Parameters.
| Parameter | Description |
|---|---|
IPDF | Document handle. |
Index | Sound-annotation ordinal (not confirmed to be the general annotation handle space). |
Options | Accepted but never read. |
SoundFileName | *(ToFile only)* Output file path. |
Return value. pdfGetAnnotSoundToFile: 1 on success, 0 on failure (invalid Index, or file-write failure caught and converted to 0). pdfGetAnnotSoundToString: pointer to a document-owned transient buffer with the raw sound bytes, or nil if Index doesn't resolve.
C# (P/Invoke)
public static extern int pdfGetAnnotSoundToFileW(IntPtr IPDF, int Index, int Options, IntPtr SoundFileName);
public static extern int pdfGetAnnotSoundToFile(IntPtr IPDF, int Index, int Options, IntPtr SoundFileName);
public static extern int pdfGetAnnotSoundToFileA(IntPtr IPDF, int Index, int Options, IntPtr SoundFileName);
Annotations
pdfGetAnnotSoundToFileW
pdfGetAnnotSoundToFile
pdfGetAnnotSoundToFileA
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.