Copy link to clipboard
Copied
Do any of You know how to determine the number of pages of a pdf-file (selected with the openDialog for example)?
Somehow I fail to grasp how to achieve that any way short of actually opening/rasterizing all pages without prior knowledge of the actual number.
I would like to use that information to determine the number of elements for a contact-sheet-like procedure beforehand.
MultiPageImporter2.0.jsx, which is an Indesign-Script by Scott Zanelli, obviously does it, but so far I’ve failed to successfully utilize his functions.
Anyway, have a nice weekend
pfaffenbichler
Ok now this works....
Install X's script amending CSx version
Then run this script amending the pdf location and CS version... (NB: will not work with CS2. CS,CS3 and CS4 should be ok)
/////////////////////////////////////////////////////////////
var pdffile = File("~/Desktop/56 pages.pdf").fsName;
////////////////////////////////////////////////////////////
var file = new File("/Applications/Adobe Photoshop CS3/Presets/Scripts/macexec.app/contents/macexec");
var pdfcnt = File("~/pdfcnt");
if(pdfcnt.exi
...Copy link to clipboard
Copied
Thanks!
Unfortunately I have failed to eliminate said pop-up yet.
Copy link to clipboard
Copied
It could be down to the OS, I was using Leopard on the laptop. I have Tiger on the G5 so I will see what happens on there. Have to go out so it will be later on.
Copy link to clipboard
Copied
I’m on Leopard, too, so it proabably isn’t worth Your time to search
further – just one of those things, I guess.
Anyway, thank You for Your time and effort!
Copy link to clipboard
Copied
I wonder how you have your Terminal preferences set?
On mine under "Shell":
When the shell exits: is set to Close the window
Prompt before closing: is set to Never
Copy link to clipboard
Copied
You’re right, my preferences were »close if shell the exited cleanly«
and »always«; now it keeps »quiet«.
Thanks for Your patience!
Copy link to clipboard
Copied
Glad you are working nowChristoph.
X this forum is a bit slow as its taken 24 hours for your reply to show up, must be because of the picture. Great information from you as usual!
Copy link to clipboard
Copied
X this forum is a bit slow as its taken 24 hours for your reply to show up, must be because of the picture. Great information from you as usual!
Actually, the first post came up blank. The post/edit with the pic is
from the morning (my TZ). The forum software just dropped the Edited
note that explained this.
Copy link to clipboard
Copied
Paul, did you change the permissions on the text file to make it an executable file? This needs to be done for OSX
Copy link to clipboard
Copied
OK so lets do it working on WIN and MAC without any shell script.
This solution is not the best but its working.
I used Try catch to solve it.
Only issue is that you should at least somehow know how many pages you expect in pdf.. this mean if you are working with books or flyers...
Then set the maxPagesCount to that number.
I am working with pdfs with max 20pages.. so i start open the 20 then 19 then 18 and when i am success i know the amount of pages.
Its not the quicker way but its usable.
var maxPagesCount = 20;
var actPagesCount = maxPagesCount;
var opts1 = new PDFOpenOptions();
opts1.usePageNumber = true;
opts1.antiAlias = true;
opts1.bitsPerChannel = BitsPerChannelType.EIGHT;
opts1.resolution = 10; //it will load faster the test page
opts1.suppressWarnings = true;
opts1.cropPage = CropToType.MEDIABOX;
myFunction = function () {
try {
app.displayDialogs = DialogModes.NO;
var fileList = openDialog();
for (i = 0; i < fileList.length; i++) {
actPagesCount = maxPagesCount;
getPagesCount(fileList,maxPagesCount);
alert(actPagesCount);
}
} catch (exception) {
alert(exception);
}
};
getPagesCount = function (checkFile, lastPageID) {
try {
for (var checkPage = lastPageID; checkPage > 0; checkPage--) {
opts1.page = checkPage;
var docRef = open(checkFile, opts1, false);
docRef.close(SaveOptions.DONOTSAVECHANGES);
actPagesCount = lastPageID;
return;
checkPage=0;
}
} catch (exception) {
// Look for next page
checkPage--;
getPagesCount(checkFile,checkPage);
}
};
Copy link to clipboard
Copied
Yes Mike came to the same conclusion a while back, so the page count is irrelevant so long as the loop has high number.
There is an example of this here...
http://www.ps-scripts.com/bb/viewtopic.php?f=10&t=1882&sid=153338764ecc6693b89cb7c1943c75c3
There is also a way of getting the page count via Bridge..
http://www.ps-scripts.com/bb/viewtopic.php?f=13&t=2769&sid=153338764ecc6693b89cb7c1943c75c3
Copy link to clipboard
Copied
Paul, drafter2, I haven’t checked out the improved solutions yet, but thanks for the heads-up.