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

Range Error: Invalid Argument value during Extracting pages

New Here ,
Apr 01, 2020 Apr 01, 2020

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

TOPICS
Create PDFs , Edit and convert PDFs , General troubleshooting , How to
3.1K
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Apr 02, 2020 Apr 02, 2020

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>

View solution in original post

Translate
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 ,
Apr 01, 2020 Apr 01, 2020

From where are you running this code?

Translate
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
New Here ,
Apr 01, 2020 Apr 01, 2020

i am running this from document javascript console.

Translate
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 ,
Apr 01, 2020 Apr 01, 2020

And how many pages are there in the file?

Translate
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 ,
Apr 01, 2020 Apr 01, 2020

Also, where is the file saved?

Translate
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
New Here ,
Apr 01, 2020 Apr 01, 2020

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.

Translate
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 ,
Apr 01, 2020 Apr 01, 2020

Strange. It's working fine for me. Is this the full code you're running, or is it part of something bigger?

Translate
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
New Here ,
Apr 01, 2020 Apr 01, 2020

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.

Translate
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 ,
Apr 01, 2020 Apr 01, 2020

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

Translate
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
New Here ,
Apr 01, 2020 Apr 01, 2020

Protected view is off, and tried with full path still same error 😞

Translate
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 ,
Apr 01, 2020 Apr 01, 2020

It's a long shot, but can you share the file with us? Or just with me?

Translate
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
New Here ,
Apr 02, 2020 Apr 02, 2020

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."

 

Translate
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 ,
Apr 02, 2020 Apr 02, 2020

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>

Translate
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
New Here ,
Apr 02, 2020 Apr 02, 2020

Many thanks try67. I am new to acrobat javascripts and hence the confusion. Executed the code directly from console and it worked. Much appreciated.

Translate
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 ,
Apr 02, 2020 Apr 02, 2020
LATEST

All of this is explained in the Article. It pays to actually read through the material. 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
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