Skip to main content
Jan 31, 2019 5:27 PM UTC
Question

Range Error on Extracting Pages

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

This topic is closed to new replies. Start a new post to keep the conversation going.

2 replies

try67
Community Expert
Community Expert
Feb 1, 2019 12:03 AM UTC

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

Translate
Legend
Jan 31, 2019 11:55 PM UTC

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)?

Translate