Skip to main content
Participating Frequently
August 18, 2025
Answered

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

  • August 18, 2025
  • 2 replies
  • 281 views
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
Correct answer PDF Automation Station

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

2 replies

PDF Automation Station
Community Expert
Community Expert
August 18, 2025

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

Nesa Nurani
Community Expert
Community Expert
August 18, 2025

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.

SergeiRAuthor
Participating Frequently
August 18, 2025

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');");