trying to get page size (crop size) adobe acrobat pdf

Hi,

We have a 2-foot wide roll-fed color proofer to which we print pdfs from Adobe Acrobat 6. We look at the pdf page dimensions and set up a new (or select an existing) page description which won’t waste much paper. That is, there’s no need to print out 3 feet of paper for a letter-size document. :slight_smile:

I’m trying to write an applescript which will choose the correct options under Page Setup depending on the pdf’s page size. I’ve been playing with the PreFab’s UI Browser and the UI Element Inspector and have a pretty good grasp on how to change the Page Setup settings.

What I can’t seem to do is obtain the page dimensions of a given pdf document. I know it might not be a simple height and width pair of numbers with bleed boxes and crop boxes and such, but if anyone has any leads on how to get any of those numbers, I’d appreciate it.

Thanks,

Adam

get bounds of —whatever to get the bounds of

Thanks for the quick reply! Just a follow-up for anyone else trying to do this: you need to specify that you’re trying to get the bounds of the PAGE. “bounds” is defined for document, too (as part of the Core Suite), and that will only get you the on-screen window dimensions. Here’s the syntax I’m going to use (and I’ll post more at my next stumbling block, I’m sure):

tell application “Acrobat 6.0.2 Professional”
get bounds of page 1 of document “Picture 1.pdf”
end tell

I found this thread when trying to do the same thing.

Acrobat 6.0.2 Pro
OS X 10.3.9

I have a pdf that is 10.5 X 10 inches that I am testing on. The script I am attempting to put together will be part of a batch sequence that checks for the widest document and stores that width as a variable to be used elsewhere.

When running in the following script.

tell application "Acrobat 6.0.2 Professional"
	get bounds of page 1 of document "20070415-20070429-01.pdf"
end tell

Returns…
{0.0, 720.0, 756.0, 0.0}
(left, top, right, bottom)

Those numbers seem incomplete. Shouldn’t the bottom be something other than 0.0?

How do I convert this to inches. Can someone please tell me what I am missing?

I have also been searching the web for some material to study up on applescripting acrobat, does anyone have any books that cover this?

Thanks in advance,

Jeff

If you haven’t cropped the document, why would the bottom be something other than 0.0 ? What number do you use when you start a measurement :wink:

Acrobat is based on the Postscript standard, so everything is in points. Not sure if it rounds.

Lastly, Adobe has a comprehensive Acrobat scripting guide available on their site for download.

-N

Heres a snippet for page crop box. That works in V7 I no longer have V6 so can’t test.

tell application "Adobe Acrobat 7.0 Pr#2CB915"
	activate
	tell active doc
		set CB_Size to crop box of page 1 as list
		-- Points to inch conversion with rounding
		set CB_Height to my RoundDecimal((((item 2 of CB_Size) - (item 4 of CB_Size)) / 72), 3, to nearest)
		set CB_Width to my RoundDecimal((((item 3 of CB_Size) - (item 1 of CB_Size)) / 72), 3, to nearest)
	end tell
	display dialog "Your crop box is." & return & return & CB_Width & " inches wide" & return & CB_Height & " inches high" giving up after 6
end tell
--
on RoundDecimal(NumberToRound, DecimalPlace, RoundType)
	set RoundFactor to 10 ^ DecimalPlace
	NumberToRound * RoundFactor
	round result rounding RoundType
	result / RoundFactor
end RoundDecimal

First, I thank you both for taking time to look over my question.

nedloh99,

I did get around to cropping the pdf and it was still returning the same results. It was like it wasn’t noticing that it was cropped. Please let me know if I understand the dictionary definition of “bounds”, my understanding is that this should return what is viewable and not the cropped off portions. If that is correct then after I cropped and saved the pdf it should have given me smaller number.

Mark67,

Thanks for the extra information. That is very helpful/useful.
The only thing and I think it may be because I am working on Acrobat 6 is that I get an AppleScript Error stating that it "Can’t get item 2 of {cropbox of page 1 of active doc of active doc of application “Acrobat 6.0.2 Professional”}.
I can return “bounds” items from the active doc but not “cropbox”. When I used “crop box” with the space between the words as you had it I got a Syntax Error.

My guess here is that Acrobat 7 has an expanded dictionary for executing from AppleScript. And to take that further, Acrobat 8 maybe has even further expanded it’s scripting capabilities from AppleScript?

If anyone has any links to information available on the dictionary’s for Acrobat 7 and/or 8 that would awesome. I looked here on MacSripter and they haven’t been posted yet. I will browse around Adobe’s website when I have the chance.

Once again, I thank you both very much for your time,

Jeff