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

Action Tool to Extract Last Page in Multiple PDFs

New Here ,
Mar 22, 2021 Mar 22, 2021

Copy link to clipboard

Copied

We have an Action that extracts the first page in multiple PDFs:

this.extractPage(6,7);

Where 0 = the first page, what can we use to = equal the last page for

multiple pdfs that vary in the number of pages that each have?

 

Thanks.

TOPICS
Edit and convert PDFs , How to

Views

886

Translate

Translate

Report

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 , Mar 23, 2021 Mar 23, 2021

You needed to only replace 0, like this:

this.extractPages(this.numPages-1);

 

And it's extractPages, not extractPage...

Votes

Translate

Translate
Community Expert ,
Mar 22, 2021 Mar 22, 2021

Copy link to clipboard

Copied

You can use: this.numPages-1

Votes

Translate

Translate

Report

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 ,
Mar 23, 2021 Mar 23, 2021

Copy link to clipboard

Copied

Actually the first statement in my original post should have read:

this.extractPage(0);

This extracts first page of multiple pdfs

 

Whether putting -1 or writing the statement as:

this.extractNumPages-1;

Neither one appears to work.

 

Also, we have a more robust script that works for extracting the first page of multiple pdfs:

/ScriptCode [/t (this.extractPages\({nStart:0, cPath: this.path.replace\("/.*\\/|\\.pdf$/ig", ""\)+"_P1"+".pdf"}\);\r\n)]

How could this be changed to extract the last page of multiple varying length pdfs?

Votes

Translate

Translate

Report

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 ,
Mar 23, 2021 Mar 23, 2021

Copy link to clipboard

Copied

You needed to only replace 0, like this:

this.extractPages(this.numPages-1);

 

And it's extractPages, not extractPage...

Votes

Translate

Translate

Report

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 ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

That got it to work... thanks!!!

 

Votes

Translate

Translate

Report

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
Advisor ,
Mar 23, 2021 Mar 23, 2021

Copy link to clipboard

Copied

Hello,

 

Give this a go......

 /* Extract Last Page */

   var re = /.*\/|\.pdf$/ig;
    var filename = this.path.replace(re,"");

    {
        for ( var i = 0;  i < this.numPages; i++ )
         if (i == this.numPages-1) {

        this.extractPages ({ nStart: i, nEnd: i, cPath : filename + "_" + (i+1) + ".pdf"});

  }
};

 

Regards,

Mike

Votes

Translate

Translate

Report

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 ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

We tried this one out... for some reason it returned an error that said it was invalid

Votes

Translate

Translate

Report

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 ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

LATEST

This script extracts all pages of a document.

Votes

Translate

Translate

Report

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