• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Insert PDF Filename to Document Title

New Here ,
Nov 05, 2020 Nov 05, 2020

Copy link to clipboard

Copied

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. 

TOPICS
Acrobat SDK and JavaScript

Views

136

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 05, 2020 Nov 05, 2020

Copy link to clipboard

Copied

LATEST

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines