PDFiumVCL Docs

JavaScriptActionCount property

この API エントリでは識別子、シグネチャ、コードブロック、PDF 用語を元の表記のまま保持します。
Component: TPdf  ·  Unit: PDFium
Number of document-level JavaScript actions stored in the PDF.

Syntax

property JavaScriptActionCount: Integer; // read only

Description

Returns the number of JavaScript actions declared at the document level — typically entries under the catalog’s /Names /JavaScript name tree (PDF 1.7 spec section 12.6.4.16) plus document-level OpenAction, DA, WC, WS, DS, WP, DP entries when their action dictionaries carry a JS stream. Field-level and annotation-level scripts are not included; those live on the annotations or AcroForm field dictionaries.

The value is 0 when the document does not load, when Active is False, or when the PDF simply contains no document-level scripts. Use JavaScriptAction[Index] to retrieve a single entry as a TPdfJavaScriptAction record (Name + Script source) or JavaScriptActions to materialise the whole array in one call.

Reading this property is cheap — PDFium only walks the name tree without executing any script. PDFiumVCL does not evaluate JavaScript; the strings returned are pure inspection data, useful for forensic analysis, removing scripts before redistribution, or surfacing a “Document contains JavaScript” warning to the user.

Remarks

Example

// Warn the user if the PDF carries embedded JavaScript.
if Pdf1.JavaScriptActionCount > 0 then
  if MessageDlg('This document contains JavaScript. Open anyway?',
    mtWarning, [mbYes, mbNo], 0) = mrNo then
    Pdf1.Active := False;

See Also

JavaScriptAction, JavaScriptActions, Permissions