Copy link to clipboard
Copied
Copy link to clipboard
Copied
Trevor×… wrote
… But I get the point.
Hi Trevor,
tested a bit on with my approach to make it a bit faster.
FWIW:
I went back to place the PDF to a graphic frame instead to the place gun.
Why?
Because I could minimize the time for creating a preview image by changing:
app.displayPerformancePreferences,
app.displaySettings[0] and
tempDoc.layoutWindows[0].viewDisplaySetting
Using the placeGun plus changing the settings above did not minimize the time for loading, a full preview image was generated every time. Using a frame placing the image did the trick. I did this with a temp document showing a layout window.
Regards,
Uwe
Copy link to clipboard
Copied
BarlaeDC​ Thanks, that seems to very much go against what acrobat interapplication communication is about.
Laubender​
Sounds better, about how much % difference does it make?
I tried a little snippet on the mac
tell application "Adobe Acrobat"
open POSIX file "/Users/Trevor/Downloads/Creative Cloud Ecosystem- Developer Engagement and Support.pdf" with invisible
set doc to document 1
set c to number of pages of doc
close doc
end tell
c
I was disappointed at the speed (about 5 seconds) and other potential problems with it. Compared with Windows acrobat interapplication communication method which tool a fraction of a second.
I will probably post a question next week on the Acrobat SDK forum to see if there's a Mac equivalent.
The 5 line VBS snippet does a good job.
Creates an invisible Acrobat process, opens the doc, counts the pages, closes the doc and the Acrobat process and returns the count all in about 150ms. There's no problems with being concerned with whats happening on an open Acrobat instance, dialogs etc.
As I type I can think of a solution to that problem, I'll try it out and if it works post it.
Copy link to clipboard
Copied
The more people vote for this feature request:
Please expose a PDF's page count to scripting – Adobe InDesign Feedback
the bigger the chance that we get it it and can bin all those awful hacks.
P.
Copy link to clipboard
Copied
https://forums.adobe.com/people/Peter+Kahrel wrote
The more people vote for this feature request:
Please expose a PDF's page count to scripting – Adobe InDesign Feedback
the bigger the chance that we get it it and can bin all those awful hacks.
Hi Peter,
already voted. Thank you for posting the link here!
Best,
Uwe
Copy link to clipboard
Copied
Hi,
IAC is there to allow you to control the Acrobat program on a users desktop, Acrobat has not been built or tested in a server environment.
And if you are looking for speed then it may be better to investigate the PDF Library, as you could build a simple application ( or even build it into your application) to open, get page number, close. all without requiring Adobe Acrobat to be installed at all.
Regards
Malcolm
Copy link to clipboard
Copied
Very useful Malcom.
I was thinking of calling a bash like
open -na "Adobe Acrobat" "/Users/Trevor/Downloads/Creative Cloud Ecosystem- Developer Engagement and Support.pdf" & echo $!
and then counting the pages and close as per PID
Copy link to clipboard
Copied
Voted too. But it does somewhat go against the crossword value of scripting 🙂
Copy link to clipboard
Copied
If one wants an Adobe API for PDFs on a server the Adobe PDF Library is available for negotiation. It does not have an IAC interface, C++ is used.
Copy link to clipboard
Copied
HI,
The PDF Library is just a collection of header files and such, but can be used to make just about any kind of application, so you could make your own application with IAC capabilities that you call when you want to count the Page numbers.
Or you could build and InDesign Server plugin that exposes a scripting interface that uses the PDF library to count the number of pages of a PDF file, you could even go as far as writing your own PDF import plug-in that could be used and it could have functionality to count the pages before import.
Just to complete the options
Regards
Malcolm
Copy link to clipboard
Copied
Hi All,
I am using this code snippet with a temporary frame (curTextFrame) to find the number of pages in the pdf. Haven't tested on CC yet.
Happy about any comment.
/*
Importiert alle Seiten des PDF Dokumentes
Besonderheit bei InDesign:
Wenn app.pdfPlacePreferences.pageNumber größer ist als die Anzahl der Seiten im
PDF Dokument, dann platziert InDesign trotzdem eine Seite
pdfAttributes.pageNumber fängt dann wieder bei "1" an.
*/
PDFPageCounter.PAGE_NAME_END = 99999;
PDFPageCounter.doSampleImport = function (curFile, curTextFrame) {
var curPageNumber = 0;
for (var i=1; i<PDFPageCounter.PAGE_NAME_END; i++) {
var curCounter = curPageNumber = i+1;
app.pdfPlacePreferences.pageNumber = curCounter;
if (curFile.exists) {
try {
curTextFrame.place(curFile);
} catch (e) {
$.writeln("cannot place file in InDesign. Corrupt file ?");
}
}
var curPDF = curTextFrame.allGraphics[0];
var placedPDFPageNumber = curPDF.pdfAttributes.pageNumber;
if (placedPDFPageNumber == 1) {
curPageNumber--;
break;
}
}
return curPageNumber;
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied