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

Javascript to Apply "Enhance Scanned Document" to a Range of Pages in multiple PDFs?

Guest
Feb 20, 2020 Feb 20, 2020

I have a folder of 1000 documents and I would like to Enhance (and Recognize Text and Optimize) only the first 10 pages of them all for now (I simply want to make the Title page, copyright, table of contents etc... searchable). I know you can do this manually by setting the page range in the main tool, but I'm hoping that there is a JavaScript command for it to be done automatically. 

 

Here's one I found for extracting pages, but I don't know what to change in order to make it work for Enhance/OCR

 

var filename = this.path;this.extractPages({nStart:8, nEnd:9, cPath:filename+"_abstract.pdf"});

TOPICS
How to , Scan documents and OCR
1.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 ,
Feb 20, 2020 Feb 20, 2020

Not possible with JavaScript.

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
Guest
Feb 28, 2020 Feb 28, 2020

I find that surprising, but thank you. Do you know of any way to do this, or at least get close to it? It seems there must be a way 

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 ,
Feb 28, 2020 Feb 28, 2020

Try using an Action, via Tools - Action Wizard.

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
Guest
Feb 28, 2020 Feb 28, 2020

I don't think it is possible there, which is why I was looking into Javascript. Doesn't Action Wizard write Javascript code behind the scenes anyway? 

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 ,
Feb 28, 2020 Feb 28, 2020

No. It can execute JS code but not all that can be done in an Action can be done in a script.

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
Guest
Feb 28, 2020 Feb 28, 2020

Thanks for clarifying.

 

It really does seem that it should be possible to do a batch optimize action on a specific page or page ranges, as you can with the specific tools. Extract 1st page(s) of all documents seems possible with the sample Javascript code I posted, for example. 

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 ,
Feb 28, 2020 Feb 28, 2020

You can do it in steps:

Action 1: Extract the pages you wish to process as new files

Action 2: Optimize those files

Action 3: Insert those files back into the originals

However, you will have to manually run each Action on its own.

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
Guest
Feb 28, 2020 Feb 28, 2020

Thanks, that seems feasible for me. I can probably figure out the first two, but I'm not sure how to do the 3rd - how would you set it to align the extracted and optimized files with the ones they came from? Would each pair need to be in their own 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 ,
Feb 28, 2020 Feb 28, 2020
LATEST

Not necessarily, but you would need to know where they are located and how they are named.

So if in Action 1 you extract the pages as <Original file name>_extracted.pdf then in Action 3 you would need to look for those extracted files and insert them into the original PDF. It's better if they are in the same folder, but then you would need to add a condition to your code to ignore files that end with "_extracted", as they will also be processed by the Action.

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