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');
The code can be found here ...Page Count
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 …
Copy link to clipboard
Copied
The code can be found here ...Page Count
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;
};
Copy link to clipboard
Copied
SuperMerlin , sorry for the late message! thanks for the link, it was really what i was looking for.