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

Extract Pages from Batch of PDF's... a "simple" JS Question?

New Here ,
May 25, 2017 May 25, 2017

So I already have some code that I found in these forums that works. Just trying to make it a bit better if possible.

I just want to extract a certain number of pages (in my script below I am extracting the first three) from a batch of PDF's, and have them saved as "Extracted OriginalFileName.pdf". So far so good. So here is that code:

var oldDoc = this; 

var newDoc = oldDoc.extractPages(0,2); 

newDoc.saveAs(oldDoc.path.replace(oldDoc.documentFileName, "Extracted " + oldDoc.documentFileName));

What I would really like it to do is go through the entire batch without any user interaction. Right now the Javascript editor window pops up and you have to click "Ok" for each document in the batch.

I did some searching, trying to find other simple scripts that behaved the same way, or other extraction scripts that might give me a clue as to what I might need to fix this relatively small issue and I have come up empty.

If someone could point me in the right direction I would appreciate it.

TOPICS
Acrobat SDK and JavaScript
671
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

correct answers 1 Correct answer

Community Expert , May 25, 2017 May 25, 2017

Instead of using the saveAs method you can specify the file-path directly as the third parameter of the extractPages method.

Also, make sure that the "Prompt User" box under the "Execute JavaScript" command in your Action is NOT ticked.

Translate
Community Expert ,
May 25, 2017 May 25, 2017

Instead of using the saveAs method you can specify the file-path directly as the third parameter of the extractPages method.

Also, make sure that the "Prompt User" box under the "Execute JavaScript" command in your Action is NOT ticked.

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 ,
May 25, 2017 May 25, 2017

Wow I feel dumb. I thought I had unchecked that "prompt user" box but I had not. Thank You.

Would using the file path method keep the files from opening as they are created?

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 ,
May 25, 2017 May 25, 2017
LATEST

I think so, yes. If not you can always call the closeDoc method on newDoc...

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