pdfToolbox provides features that are designed specifically to make debugging of Script Variables easier:
- Variable values are listed when "Log Profile Execution" is active
The Console is available below the Script Editor if "Show evaluation result" in enabled.
In the example above the check that would fill the app.doc.result.checks.hits array has to be manually performed before the code in this Variable can be debugged. Only then the variable "loc_triggerarray" has a meaningful value. It is printed to the Console via console.log using "pretty printing" with the optional parameters null,"\t".
This screenshot shows parts of the app object after that has been output via console.log(JSON.stringify(app,null,"\t")) and copied from the Console into the Sublime editor. The part above shows the app.doc.result.checks part with hits and their trigger values.
Variable values listed in a logfile created via Log Profile Execution
If you are using Script Variables in a Process Plan you may need to know how Variable values are changed throughout processing. You enable logging via the options menu in the pdfToolbox main window.
If switched on a logfolder will be created that amongst other things includes a log file "process.log". The other contents of this folder are explained in further detail in a different article of this documentation: http://help.callassoftware.com/m/pdftoolbox9-en/l/656888.
All Variables that are stored in app.vars so that they are available throughout a Process Plan are listed for each of the steps of the Process Plan with their current values.
This screenshot shows that the variable "hitarray" had two entries in step 3 and was empty in step 4. (The empty lines before, between and after these two steps have been added to make the example more readable.)
Debugging with MS Visual Studio Code (version 10.1)
In order to set this up you need to:
- Install nodeJS (https://nodejs.org/en/download/)
- Install MS Visual Code (https://code.visualstudio.com/) in the default location
- Mac Only: Install MS Visual Studio Code command-line tools.
On Windows and Linux this should be automatically available after installing Visual Studio Code. On macOS, you need to open "View" -> "Command Palette…" and select "Shell Command: Install 'code' command in PATH" (further information on this can be found here).
Then you can use MS Visual Studio Code for debugging.