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

Using javascript to extract pages from PDF

New Here ,
Sep 13, 2021 Sep 13, 2021

Each month I get a large pdf file that I need to extract pages from and resave. The page numbers rarely change so this can had been working:

 

this.extractPages(0,1, "table1.pdf");

this.extractPages(2,15, "table2.pdf");

etc. for many more tables.

 

I recently "upgraded" to Adobe Acrobat Pro DC version 2021.005.20058

 

the code no longer works. I get an error message:

RaiseError: The file may be read-only, or another user may have it open. Please save the document with a different name or in a different folder. Doc.extractPages:1:Console undefined:Exec

 

There is no possible way for another user to have the file open - I just created it. I have searched on this error and seen many solutions, however none of them solve the problem.

TOPICS
Acrobat SDK and JavaScript
2.3K
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 ,
Sep 13, 2021 Sep 13, 2021

Go to Edit (or the Acrobat app menu if you're on a Mac) - Preferences - Security (Enhanced) and disable Protected View Mode (or something similar).

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 ,
Sep 14, 2021 Sep 14, 2021

That's not it. Using a PC, Protected View is already off.

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 ,
Sep 14, 2021 Sep 14, 2021

How many pages are there in the file? What's the name of the original file? Where is the original file located (under what folder)?

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 ,
Sep 14, 2021 Sep 14, 2021

Original file has 1084 pages, named "alltables.pdf".

 

all in folder c:\macros\adobe

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 ,
Sep 14, 2021 Sep 14, 2021

Is there already a file with the name you're trying to save it under in that folder?

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 ,
Sep 14, 2021 Sep 14, 2021

No, i don't have any other pdfs in that folder. 

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 ,
Sep 14, 2021 Sep 14, 2021

Are you able to manually extract those pages from the file?

From where are you running the 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 ,
Sep 14, 2021 Sep 14, 2021

I can extract manually. I am running the code by opening "alltables.pdf", then go to tools > javascript and open the debugger. I paste the code from post #1 into the console, highlight the code, and execute by ctrl+enter. When I do this, I get the error message.

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
LEGEND ,
Sep 14, 2021 Sep 14, 2021

Protected View is NOT the option that matters. You need to turn off Protected MODE. The job of this option is to stop files from being written without a prompt, and so if you want to do that, the option will stop you...

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 ,
Sep 14, 2021 Sep 14, 2021
LATEST

Ah, I see. That option is checked, but also unable to be changed (grayed out). I think I'll have to check with my workplace's IT staff to try and chnage it. Thanks for your help.

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