THotPDF.GetLoadedJavaScriptSource Method
Reads the source code of the document-level JavaScript script with the specified name in the loaded PDF document
Declaration
function GetLoadedJavaScriptSource(const AName: AnsiString): AnsiString;
Unit
HPDFDoc
Parameters
| Name | Purpose |
|---|---|
AName | The name of the script entry in the JavaScript name tree, used to locate the target script |
Return value
Returns the JavaScript source code string corresponding to the specified name; returns an empty string if the name does not exist
Usage notes
- Document-level JavaScript in a PDF lives in the name tree (Names > JavaScript); you need the correct script name to locate it
- Some PDF generation tools use FlateDecode compression to store JavaScript streams; this method returns the uncompressed original script text
- For security reasons, do not directly execute JavaScript code extracted from third-party PDFs without the user's knowledge