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

Show the number of pages in the pdf file

Engaged ,
Oct 01, 2020 Oct 01, 2020

Copy link to clipboard

Copied

Hello everyone! Pessol is there any possibility to display a message informing the number of pages of a PDF file when executing this command?

pdfFolder = File.openDialog ('Select the PDF file.', 'PDF file: *. pdf');

 

TOPICS
Actions and scripting

Views

336

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

Guide , Oct 05, 2020 Oct 05, 2020

The code can be found here ...Page Count 

Votes

Translate

Translate
Adobe
Community Expert ,
Oct 05, 2020 Oct 05, 2020

Copy link to clipboard

Copied

Do you mean an alert after OK-ing the openDialog or a field in a dialog that indicates the pagenumber when you select a pdf and before OK- or canceling? 

 

If I remember correctly one can assess a pdf’s number of pages via BridgeTalk but there were cases where the numbers were wrong – I think pdfs that were created by combining pages or some such … 

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
Guide ,
Oct 05, 2020 Oct 05, 2020

Copy link to clipboard

Copied

The code can be found here ...Page Count 

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
Engaged ,
Oct 05, 2020 Oct 05, 2020

Copy link to clipboard

Copied

Hi c.pfaffenbichler, when I find the .pdf file and click OK, inform the number of pages in it! I think the script for the link indicated by the SuperMerlin , is the same as the one you mentioned about BridgeTalk, here it worked with a modification. Too bad it only works with Bridge open, it can make the message a little slow.

 

pdfFolder = File.openDialog ('Select the PDF file.', 'PDF file: *. pdf');
alert(getPDFCount(pdfFolder))

function getPDFCount(filePath) {
if (!BridgeTalk.isRunning( "bridge" ) ) BridgeTalk.launch("bridge");   
   var filePath=File(filePath);
      var data;
   if ( BridgeTalk.isRunning( "bridge" ) ) {
     var bt = new BridgeTalk();
     bt.target = "bridge";
     bt.body = 'function a(){app.document.setPresentationMode("browser","' +filePath.path+'");tn = new Thumbnail( File("'+filePath+'") ); tn.refresh(); return tn.core.itemContent.pageCount}a();';
     bt.onResult = function( inBT ) { data = eval(inBT.body)  }
     bt.onError = function( inBT ) { data = ''; }
     bt.send();
     bt.pump();
     $.sleep( 100 );
     var timeOutAt = ( new Date() ).getTime() + 5000;
     var currentTime = ( new Date() ).getTime();
     while ( ( currentTime < timeOutAt ) && ( undefined == data ) ) {
        bt.pump();
        $.sleep( 100 );
        currentTime = ( new Date() ).getTime();
       }
      }
      if ( undefined == data ) {
        data = '';
      }
     return data;
};

 

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
Engaged ,
Oct 05, 2020 Oct 05, 2020

Copy link to clipboard

Copied

LATEST

 SuperMerlin , sorry for the late message! thanks for the link, it was really what i was looking for.

 

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