Skip to main content
January 31, 2019
Question

Range Error on Extracting Pages

  • January 31, 2019
  • 2 replies
  • 341 views

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 has been closed for replies.

2 replies

try67
Community Expert
Community Expert
February 1, 2019

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

Legend
January 31, 2019

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