Copy link to clipboard
Copied
I am getting "RangeError: Invalid argument value" error when i run this script
this.extractPages(1, 6, "test.pdf");
but when i run script without file name as shown below, it runs fine and creates a tmp pdf file.
this.extractPages(1, 6);
please can someone let me know steps to fix this issue so that i can create a file with name test.pdf
Copy link to clipboard
Copied
You said you were running it from the console... You can't use it from a doc-level script.
See the documentation of this method:
<Quote>
Note: If the cPath parameter is specified, this method can only be executed during a batch and console
event, or through an external call (for example, OLE). See Privileged versus non-privileged context
for details. The event object contains a discussion of JavaScript events.
</Quote>
Copy link to clipboard
Copied
From where are you running this code?
Copy link to clipboard
Copied
i am running this from document javascript console.
Copy link to clipboard
Copied
And how many pages are there in the file?
Copy link to clipboard
Copied
Also, where is the file saved?
Copy link to clipboard
Copied
Many thanks try67 for your swift responses.
main pdf file is on my desktop, i tried it from one of my local folders as well, still same error.
The pdf has over 600 pages.
Copy link to clipboard
Copied
Strange. It's working fine for me. Is this the full code you're running, or is it part of something bigger?
Copy link to clipboard
Copied
this is the full code i am running, once this is successful i will be building some more logics on top of this. Do i have to make any changes to any settings in my acrobat pro DC.
Copy link to clipboard
Copied
I don't think so... Maybe check that Protected View is Off under Edit - Preferencs - Security (Enhanced).
Does it work if you specify the full file path, instead of just the file-name?
For example:
this.extractPages(1, 6, "/C/Temp/test.pdf");
Copy link to clipboard
Copied
Protected view is off, and tried with full path still same error 😞
Copy link to clipboard
Copied
It's a long shot, but can you share the file with us? Or just with me?
Copy link to clipboard
Copied
i am using sample pdf file from this link
https://acrobatusers.com/tutorials/extracting-pages-pdf-acrobat-javascript/
Direct link to PDF file: http://www.windjack.com/PDFSamples/NelsonsInc_Employee1040s.pdf
Steps I follow to execute the script
1) Save the file in my local drive
2) Open it with acrobat pro DC
3) Click tools - javascript
4) Click Document Javascripts
5) add a new script and enter this
this.extractPages(5, 5, "TestExtract1.pdf");
6) Close the editor and click debugger - i get this error "RangeError: Invalid argument value."
Copy link to clipboard
Copied
You said you were running it from the console... You can't use it from a doc-level script.
See the documentation of this method:
<Quote>
Note: If the cPath parameter is specified, this method can only be executed during a batch and console
event, or through an external call (for example, OLE). See Privileged versus non-privileged context
for details. The event object contains a discussion of JavaScript events.
</Quote>
Copy link to clipboard
Copied
Many thanks try67. I am new to acrobat javascripts and hence the confusion. Executed the code directly from console and it worked. Much appreciated.
Copy link to clipboard
Copied
All of this is explained in the Article. It pays to actually read through the material.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more