Copy link to clipboard
Copied
Is there any way to count multi-sized pages in Acrobat?
For example, I have a 300pg document with a number of different page sizes, anywhere from 8.5x11 to 11x17 to 24x36. They are all mixed up - not in order by size. I need to count out how many of each size there are.
I'm on a Mac with Pro DC if it matters.
Copy link to clipboard
Copied
I just posted a script that does something very similar to that to the post directly above yours... You can use the output from it in Excel and then count it there. See: https://community.adobe.com/t5/acrobat/export-dimensions-value-to-excel-sheet/td-p/10776182
Copy link to clipboard
Copied
It is easy enough to create a script to count various page sizes. Do you know anything about scripting
Copy link to clipboard
Copied
Not that well. Im good at coping and pasting
Copy link to clipboard
Copied
The basics are provided in Try67's post. The code just needs to be modified for comparing and counting page sizes.
Here I've changed it to build an object that counts specific page sizes. Now all you need to do is put the size count info into the form that need.
var oPageSizes = {};
for (var p=0; p<this.numPages; p++) {
var aRect = this.getPageBox("Crop", p);
var width = util.printf("%0.2f",(aRect[2] - aRect[0])/72);
var height = util.printf("%0.2f",(aRect[1] - aRect[3])/72);
var strKey = width+"x"+height;
if(oPageSizes[strKey]) oPageSizes[strKey]++;
else oPageSizes[strKey] = 1;
}
Copy link to clipboard
Copied
So do I need to combine Try67 in front of the code you wrote? Or is yours all I need? And do I put the size count info into the form?
Copy link to clipboard
Copied
You only need the code I provided. It builds an object where the name of each entry is a page size and the values are the number of pages of that size. This code is intended to be run in the Console Window. You'll find a tutorial on the console here:
https://www.pdfscripting.com/public/Free_Videos.cfm#JSIntro
To display the contents of the page size object, run this code in the console after running the code block I provided above.
oPageSizes.toSource()
Copy link to clipboard
Copied
Thank you so much for your extended effort to help me. I will go through and get my education through the info you have provided.
Copy link to clipboard
Copied
I believe I've figured this out to do exactly what I want!
I though I'd share here on the outside chance someone is looking for the same kind of thing...
I saved this as a Custom Command in Acrobat.
var msgText = "There are " + this.numPages + " pages in this document\n";
// counters
var numA3 = 0;
var numLegal = 0;
var numUSL = 0;
// helper function to compare a number with some wiggle room - we look for portrait and landscape possibilities
function inRange(wid,hei,targetWid,targetHei) {
var wiggle = 200; // amount of error to allow
return (wid>=(targetWid-wiggle) && wid<=(targetWid+wiggle)) && (hei>=(targetHei-wiggle) && hei<=(targetHei+wiggle)) || (hei>=(targetWid-wiggle) && hei<=(targetWid+wiggle)) && (wid>=(targetHei-wiggle) && wid<=(targetHei+wiggle))
}
for (pagenum=0;pagenum<this.numPages;pagenum++) {
var pbox = this.getPageBox("Crop",pagenum);
var width = (pbox[2] - pbox[0]);
var height = (pbox[1] - pbox[3]);
var recognized = false;
if (inRange(width,height,841,1188)) { numA3++; recognized = true; }
if (inRange(width,height,612,1008)) { numLegal++; recognized = true; }
if (inRange(width,height,594,792)) { numUSL++; recognized = true; }
// etc...
if (!recognized) msgText += ("Page " + (pagenum+1) + " has a width of " + (width/72).toFixed(2) + " and a height of " + (height/72).toFixed(2) + "inches\n");
}
msgText += numA3 + " A3 pages\n" + numLegal + " Legal pages\n" + numUSL + " US Letter pages\n" + (this.numPages++ - (numA3+numLegal+numUSL)) + " other pages";
app.alert(msgText);
Thank you all for your help!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now