Skip to main content
Participant
November 6, 2020
Question

Insert PDF Filename to Document Title

  • November 6, 2020
  • 1 reply
  • 248 views

I am trying to apply some JavaScript via the Acrobat DC Action Wizard using the Execute JavaScript tool to automatically insert the filename of the PDF into the document title field (without the ".pdf"). I found a chunk of script and pasted it in, but I get the following error:

 

SyntaxError: illegal character

3: at line 4

 

The full code:

 

/* Put script title here */

 

\r\n//Begin script
\r\n\r\nvar strFilename = "";
\r\nvar strChar;
\r\nvar i = this.path.length;
\r\n\r\ndo {\r\nstrChar = this.path.substr\(i-1,1\)
\r\n//console.println\(strChar\);
\r\nstrFilename = strChar + strFilename;
\r\ni--;\r\n}
\r\nwhile \(strChar != "/"\)
\r\nstrFilename = strFilename.substring\(1,strFilename.length-4\);
\r\n\r\nthis.title = strFilename;
\r\n\r\n//End script\r\n).

 

I don't know enough coding to understand where the illegal character is. 

This topic has been closed for replies.

1 reply

Legend
November 6, 2020

The \r stuff shows this was just part of a script. In this case, you can't just copy this small part. Start with the whole thing.