Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Count Multi-Sized Pages in Acrobat.

New Here ,
Dec 02, 2019 Dec 02, 2019

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.

TOPICS
Edit and convert PDFs , General troubleshooting , How to , Scan documents and OCR , Standards and accessibility
2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 02, 2019 Dec 02, 2019

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 02, 2019 Dec 02, 2019

It is easy enough to create a script to count various page sizes. Do you know anything about scripting

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 02, 2019 Dec 02, 2019

Not that well. Im good at coping and pasting

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 03, 2019 Dec 03, 2019

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;
}

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 04, 2019 Dec 04, 2019

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?

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 04, 2019 Dec 04, 2019

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()

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 05, 2019 Dec 05, 2019

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 14, 2020 Jan 14, 2020
LATEST

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!

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