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

276

Likes

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

Most Valuable Participant , 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...

Likes

Translate

Translate
Most Valuable Participant ,
Mar 22, 2021 Mar 22, 2021

Copy link to clipboard

Copied

You can use: this.numPages-1

Likes

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?

Likes

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
Most Valuable Participant ,
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...

Likes

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!!!

 

Likes

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
Enthusiast ,
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

Likes

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

Likes

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

Copy link to clipboard

Copied

LATEST

This script extracts all pages of a document.

Likes

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