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

Acrobat Javascript - Extract Pages with Different file names

Community Beginner ,
Jan 12, 2024 Jan 12, 2024

Copy link to clipboard

Copied

Hi, I have an Action that I have been running and hoping to simplify so it can be shared with others on my team. I have an action that creates a temp file and then extracts pages and gives them a file name in a designated folder. The Action currently has a separate entry for Javascript to extract the five pages and works. I am hoping to get this to one so I can set the output folder as a variable and quickly update this for each member of the team. 

this.extractPages({nStart:0, nEnd:1, cPath: "C:/Users/user/Downloads/Folder/Renamed/form name 5.pdf"});
this.extractPages({nStart:2, cPath: "C:/Users/user/Downloads/Folder/Renamed/form name 4.pdf"});
this.extractPages({nStart:5, cPath: "C:/Users/user/Downloads/Folder/Renamed/form name 3.pdf"});
this.extractPages({nStart:6, cPath: "C:/Users/user/Downloads/Folder/Renamed/form name 1.pdf"});
this.extractPages({nStart:4, cPath: "C:/Users/user/Downloads/Folder/Renamed/form name 2.pdf"});

What I was trying to do was define a variable with the folder name and then call that in the cPath: 

var RenamedFolder = C:/Users/user/Downloads/Folder/Renamed/;
this.extractPages({nStart:0, nEnd:1, cPath: RenamedFolder + "form name 2.pdf"});
this.extractPages({nStart:2, cPath: RenamedFolder + "form name 1.pdf"});

I am very new to Javascript and am kind of learning as I go. Is this possible? Or is there a better way to simplify this Action? 

TOPICS
Create PDFs , How to , JavaScript , PDF

Views

94

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
Community Beginner ,
Jan 12, 2024 Jan 12, 2024

Copy link to clipboard

Copied

I made a few edits and am seeing some odd behavior. This script worked one time but then gave an error when trying it again. 

var RenamedFolder = "C:/Users/user/Downloads/Folder/Renamed/";
this.extractPages({nStart:0, nEnd:1, cPath: RenamedFolder + "form1.pdf"});
this.extractPages({nStart:2, nEnd:2, cPath: RenamedFolder + "form2.pdf"});
this.extractPages({nStart:5, nEnd:5, cPath: RenamedFolder + "form3.pdf"});
this.extractPages({nStart:6, nEnd:6, cPath: RenamedFolder + "form4.pdf"});
this.extractPages({nStart:4, nEnd:4, cPath: RenamedFolder + "form5.pdf"});

When I run in the debugger, this is the error. 

Exception in line 1 of function top_level, script Console:Exec

NotAllowedError: Security settings prevent access to this property or method.
Doc.extractPages:1:Console undefined:Exec

undefined

Again, the script worked one time but then started giving this error when I tested it a second time. 

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
Community Expert ,
Jan 12, 2024 Jan 12, 2024

Copy link to clipboard

Copied

The syntax for the folder is not quite correct. It should be:

var RenamedFolder = "/C/Users/user/Downloads/Folder/Renamed/";

If it's still giving you the same error message it probably means the file is protected or digitally signed, so you can't export pages from it.

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
Community Beginner ,
Jan 16, 2024 Jan 16, 2024

Copy link to clipboard

Copied

LATEST

Thanks for the help. I'm not sure why but restarting Acroabt resolved the security errors and the script is running perfectly now. 

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