pdfGetJavaScriptCount
Read back a document-level named JavaScript's source — by
const char* __stdcall pdfGetJavaScript(PPDF IPDF, uint32_t Handle, uint32_t* Len, BOOL32* Unicode);
const char* __stdcall pdfGetJavaScriptEx(PPDF IPDF, const char* Name, uint32_t* Len, BOOL32* Unicode);
const char* __stdcall pdfGetJavaScriptName(PPDF IPDF, uint32_t Handle, uint32_t* Len, BOOL32* Unicode);
int32_t __stdcall pdfGetJavaScriptCount(PPDF IPDF);
function pdfGetJavaScript(const IPDF: PPDF; Handle: Cardinal; var Len: Cardinal; var Unicode: LongBool): PAnsiChar; stdcall;
function pdfGetJavaScriptEx(const IPDF: PPDF; const Name: PAnsiChar; var Len: Cardinal; var Unicode: LongBool): PAnsiChar; stdcall;
function pdfGetJavaScriptName(const IPDF: PPDF; Handle: Cardinal; var Len: Cardinal; var Unicode: LongBool): PAnsiChar; stdcall;
function pdfGetJavaScriptCount(const IPDF: PPDF): Integer; stdcall;
Purpose. Read back a document-level named JavaScript's source — by handle (pdfGetJavaScript), by name (pdfGetJavaScriptEx), or read just its name given a handle (pdfGetJavaScriptName) — this is the document /Names /JavaScript tree, not a per-field/per-object action script (see pdfGetJavaScriptAction/Action2, Action Getters).
Description. pdfGetJavaScript's output Unicode is always forced to False — its underlying QueryJSActionText only exposes a narrow (ANSI/byte) form regardless of how the script was originally stored. By contrast, pdfGetJavaScriptEx and pdfGetJavaScriptName both genuinely report a real, source-derived Unicode flag (from GetJSScriptByName/GetJSNameByHandle's own U: Boolean out-param) — a real inconsistency between the by-handle and by-name/name-only retrieval paths for the same underlying data.
Parameters.
| Parameter | Description |
|---|---|
IPDF | Document handle. |
Handle | *(GetJavaScript/Name)* JavaScript entry handle. |
Name | *(Ex only)* JavaScript entry name to look up. |
Len | Output: byte/char length. |
Unicode | Output: whether the returned text is wide. Always False for pdfGetJavaScript; genuinely variable for Ex/Name. |
Return value. Pointer to the script/name text (transient buffer), or nil if the target doesn't resolve. pdfGetJavaScriptCount: total document-level JavaScript entry count; 0 if IPDF invalid.
See also. pdfGetJavaScriptAction (the per-object action-script counterpart).
C# (P/Invoke)
public static extern int pdfGetJavaScriptCount(IntPtr IPDF);
Getters
pdfGetJavaScriptCount
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.