Range Error on Extracting Pages

New Here ,
Jan 31, 2019

Copy link to clipboard

Copied

Need some help with the following code.  Everything works, ie export pages based on bookmarks with temp file names.  That is until I add code to go and export the file with the name of its bookmark.  Then I get the following error.  Any help would be appreciated thanks.

RangeError: Invalid argument value.

Doc.extractPages:7:Document-Level:test

This works

console.clear();

oDoc = this;
bkTrgt = []


this.bookmarkRoot.children.forEach(function(a){a.execute();bkTrgt.push(pageNum);})

bkTrgt.forEach(function(a,i,k){oDoc.extractPages(k,((i+1)<k.length)?k[i+1]-1:oDoc.numPages-1);});

This Doesnt

console.clear();

oDoc = this;
bkTrgt = []


this.bookmarkRoot.children.forEach(function(a){a.execute();bkTrgt.push(pageNum);})

bkTrgt.forEach(function(a,i,k){oDoc.extractPages(k,((i+1)<k.length)?k[i+1]-1:oDoc.numPages-1,oDoc.bookmarkRoot.children.name + ".pdf");});

TOPICS
Acrobat SDK and JavaScript, Windows

Views

104

Likes

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

Range Error on Extracting Pages

New Here ,
Jan 31, 2019

Copy link to clipboard

Copied

Need some help with the following code.  Everything works, ie export pages based on bookmarks with temp file names.  That is until I add code to go and export the file with the name of its bookmark.  Then I get the following error.  Any help would be appreciated thanks.

RangeError: Invalid argument value.

Doc.extractPages:7:Document-Level:test

This works

console.clear();

oDoc = this;
bkTrgt = []


this.bookmarkRoot.children.forEach(function(a){a.execute();bkTrgt.push(pageNum);})

bkTrgt.forEach(function(a,i,k){oDoc.extractPages(k,((i+1)<k.length)?k[i+1]-1:oDoc.numPages-1);});

This Doesnt

console.clear();

oDoc = this;
bkTrgt = []


this.bookmarkRoot.children.forEach(function(a){a.execute();bkTrgt.push(pageNum);})

bkTrgt.forEach(function(a,i,k){oDoc.extractPages(k,((i+1)<k.length)?k[i+1]-1:oDoc.numPages-1,oDoc.bookmarkRoot.children.name + ".pdf");});

TOPICS
Acrobat SDK and JavaScript, Windows

Views

105

Likes

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
Jan 31, 2019 0
Most Valuable Participant ,
Jan 31, 2019

Copy link to clipboard

Copied

Did you follow the documentation carefully? So, are you sure this is a Safe Path (we can't know, because you don't show us the bookmarks)? And, are you running it from a trusted environment (you don't say how you run it)?

Likes

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
Reply
Loading...
Jan 31, 2019 1
try67 LATEST
Most Valuable Participant ,
Jan 31, 2019

Copy link to clipboard

Copied

The code is very vague. Try adding some formatting to it, some comments and some debugging commands...

Likes

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
Reply
Loading...
Jan 31, 2019 0