|
Registers a document-level named JavaScript function in the Catalog /Names /JavaScript name tree (ISO 32000-1 §7.7.4.4 + §12.6.4.16). AcroForm widget actions, document-open actions, and other JavaScript bodies can invoke the registered function by name through the viewer’s JavaScript engine (Adobe Acrobat, Foxit, and other compatible viewers).
Sintassi Delphi:
procedure RegisterDocumentJavaScript(const Name, Body: AnsiString);
Parametri
Name è la chiave unica sotto cui il sorgente JS viene archiviato nel name tree. Case-sensitive secondo PDF 1.7 §7.9.6. Vuoto Name solleva.
Body is the raw JavaScript source. HotPDF does not parse or validate the JS – the caller is responsible for syntactic correctness. Typical callers pass a complete function declaration (function GreetUser() { app.alert("hello"); }). Empty Body solleva.
Descrizione
Each call adds a (key, indirect dict) pair to the Catalog /Names /JavaScript name tree in EndDoc tempo. Ogni Body registrato diventa il proprio << /S /JavaScript /JS (body) >> , pronto per essere referenziato per nome da qualsiasi altra azione o contesto JS. Utile per condividere una libreria di helper di validazione, formattazione o calcolo tra molti widget senza duplicare il sorgente in ciascuno /A azione.
Registering the same Name due volte solleva, così i chiamanti non perdono silenziosamente la prima definizione.
Cancelli di conformità
Solleva con qualsiasi non vuoto PDFACompliance setting (ISO 19005-1 §6.6.1 / ISO 19005-2 §6.5.1 / ISO 19005-3 §6.5.1 prohibit all JavaScript actions across PDF/A levels). Raises under any non-empty PDFXCompliance (i flussi prepress ISO 15930 rifiutano lo scripting interattivo). Alza automaticamente la versione del documento Version to PDF 1.3 when needed; refuses under StrictVersionLock if the chosen version pre-dates PDF 1.3.
Esempio
PDF := THotPDF.Create(nil);
PDF.FileName := 'form.pdf';
PDF.BeginDoc;
PDF.RegisterDocumentJavaScript('GreetUser',
'function GreetUser() { app.alert("Hello"); }');
PDF.RegisterDocumentJavaScript('ValidateNumber',
'function ValidateNumber(v) { if (isNaN(v)) app.alert("Not a number"); }');
// ... AcroForm widget /A action can then call: ValidateNumber(this.value);
PDF.EndDoc;
Availability
HotPDF v2.119.14. PDF 1.3+ feature; HotPDF auto-bumps the document Version unless StrictVersionLock è impostato.
Vedi anche: Supporto AcroForm, THPDFActionScriptType
|