Skip to main content
Participating Frequently
Aug 18, 2025 1:08 PM UTC
Answered

please help with correct javascript syntax '/n' inside addScript

this.addScript("Main", "var arr =this.getField('recList').value.split('\n');")
Exception in line 1 of function top_level, script Console:Exec

GeneralError: Operation failed.
Doc.addScript:1:Console undefined:Exec

undefined
PDF Automation Station
Community Expert
Aug 18, 2025 2:36 PM UTC

You need to double escape \n like this \\n

4 replies

PDF Automation Station
Community Expert
Community Expert
Aug 18, 2025 2:36 PM UTC

You need to double escape \n like this \\n

Translate
Nesa Nurani
Community Expert
Community Expert
Aug 18, 2025 1:55 PM UTC

this.addScript() cannot be executed from the JavaScript console or from field/button actions due to Acrobat’s security restrictions. It is intended for use in trusted contexts, such as batch processes (Action Wizard in Acrobat Pro) or other automation workflows, where document-level scripts can be safely installed.

Translate
SergeiRAuthor
Participating Frequently
Aug 18, 2025 2:17 PM UTC

its folder level script actually

its executed from the JavaScript console

i found solution 

this.addScript("Main", "var array =this.getField('recList').value.split('\\r');");

 

Translate