Show the number of pages in the pdf file

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

127

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

1 Correct Answer

Guide , Oct 05, 2020
SuperMerlin Guide , Oct 05, 2020
The code can be found here ...Page Count 

Likes

Translate

Translate
Jump to answer Jump to answer
LEGEND ,
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 … 

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Guide ,
Oct 05, 2020

Copy link to clipboard

Copied

The code can be found here ...Page Count 

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Contributor ,
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;
};

 

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Shulipa Bernad AUTHOR LATEST
Contributor ,
Oct 05, 2020

Copy link to clipboard

Copied

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

 

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more