Copy link to clipboard
Copied
I'm working with VBA and Acrobat. I want to examine a .pdf file to see if it's 8.5x11" in size. If it's not that size, I'd like to change it to be that size (or create a copy of the document that is 8.5x11" in size). Most of the documents are only one page long.
Any suggestions on the best way to do this without requiring any interaction from the user?
Thanks.
Copy link to clipboard
Copied
You can use this code to achieve it:
if (this.numPages>1) app.alert("This file has more than one page!");
else {
var cropBox = this.getPageBox("Crop", 0);
var pageWidth = cropBox[2]-cropBox[0];
var pageHeight = cropBox[1]-cropBox[3];
if (pageWidth!=612 && pageHeight!=792) app.alert("The dimensions of this page are not 8.5\" x 11\".");
}
I used the Crop box, as it's the default one, but you can change it to something else, or test multiple boxes, if you wish.
Copy link to clipboard
Copied
How do you plan to change the size? Please be specific about what you would do in the user interface to change the size.
Copy link to clipboard
Copied
Currently we copy the file to a Distiller folder. It gets picked up from the "input" folder, converted to a new file and put into the "output" folder. But this requires the user to configure their Distiller correctly, and I'm trying to get away from that. If there was a way to force Distiller to listen to a specific folder, without the user turning that on, I could do that. However, this might result in unnecessary processing if the original file was already 8.5x11" in size.
Or people sometimes print to their Acrobat PDF printer using 8.5x11" output settings.
Copy link to clipboard
Copied
Distiller has a watched folder feature. The only acceptable input is PostScript. However... Using print-to-PDF to resize is considered a desperate last resort as it often loses features, quality, and information. However... Acrobat doesn't offer any neat "scale to resize" feature otherwise.
Copy link to clipboard
Copied
Why not? The Preflight tool of Acrobat DC/2019 has a Scale Pages command, I believe.
Copy link to clipboard
Copied
For another project I created a JavaScript function that does this. But it requires installing the .js file on the user's computer, which I was hoping to avoid. Maybe that's the only way to do this, still. I only have 10 users using this, so it's not too burdensome.
Copy link to clipboard
Copied
Is there a way for me to programmatically enable a specific "watched folder"? The only thing I've found is to tell users "make sure you configure Distiller like this".
Copy link to clipboard
Copied
Oh, yes. Can it be automated?
Copy link to clipboard
Copied
You can use JS to run a Preflight Profile, but I'm not sure whether it will prompt you for the page size to use in each run, or if it can be defined in the profile's properties.
Copy link to clipboard
Copied
So back to the first part of my original question: before I try to "resize" the document in question, is there a way to tell whether it's already at an 8.5x11" size? It's possible virtually all of my documents are already the right size, and I'll only need to pop up a message to the user that they need to fix the occasional document.
Copy link to clipboard
Copied
Are your documents all just one page?
Copy link to clipboard
Copied
I'm pretty sure of that. And I'm willing to test that first. I.e.,
1. check to see if the document is only one page long (I know how to do that from VBA using the IAC (interapplication communication). If it's not, pop up a message to the user that they have to do something manually.
2. check to see if the one page document is 8.5x11". If not, pop up a message to the user.
If everything is one page, 8.5x11", I'm good.
If there are a lot of exceptions, I'll come up with something that deals with that.
Copy link to clipboard
Copied
You can use this code to achieve it:
if (this.numPages>1) app.alert("This file has more than one page!");
else {
var cropBox = this.getPageBox("Crop", 0);
var pageWidth = cropBox[2]-cropBox[0];
var pageHeight = cropBox[1]-cropBox[3];
if (pageWidth!=612 && pageHeight!=792) app.alert("The dimensions of this page are not 8.5\" x 11\".");
}
I used the Crop box, as it's the default one, but you can change it to something else, or test multiple boxes, if you wish.
Copy link to clipboard
Copied
JavaScript can inspect the page size of each page. Consider carefully what you mean by page size - crop box or media box? Follow page rotation or no?
Copy link to clipboard
Copied
When I say page size, I mean what displays when in the bottom left corner of an Acrobat document (sometimes requires a hover, sometimes it displays on the status line of the document). But I'm willing to use the correct term, if there's a better term for this.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more