Hi,
Seems you can get the title and creator of a pdf using this script
tell application “Adobe Acrobat Pro”
set doc_title to get info of document 1 key “Title”
end tell
but I need to get the page size. Any suggestions?
Thanks.
Hi,
Seems you can get the title and creator of a pdf using this script
tell application “Adobe Acrobat Pro”
set doc_title to get info of document 1 key “Title”
end tell
but I need to get the page size. Any suggestions?
Thanks.
I don’t have Adobe Acrobat (Pro) installed, but if you want to get the page dimensions (media box) of a PDF you can use code as follows:
tell application "Adobe Acrobat Professional"
set mbox to media box of page 1 of document 1
end tell
Of course a single PDF can contain different page sizes, so you might need to iterate over all pages to find all available page sizes.
Thank you for responding to my question. I appreciate it.
Trouble is is that gives me dimensions in something called PDF space. Here is my real deal. I often have pdfs which I have to crop. Of course, in Acrobat crop doesn’t mean actually crop. So what I’m trying to do is get the page size after the crop, or the crop box, as a simple w x h statement. Instead, I get the dimensions in Pdf Space, such as (crop box) {18.0, 720.0, 7320.0, 18.0} when the original media box was {0.0, 720.0, 720.0, 0.0}…I get that the media box is 10 x 10 inches, but I have no clue as to how to figure a way to convert the crop box dimensions into regular page dimensions.
I did check the SDK but the only page that talks of PDF space doesn’t really explain it.
Thank you again.
Hi Paeon,
Yes, the whole PDF space can be a bit confusing, I also struggled with this subject before. But the return value of «media box» or «crop box» is just a list of four numbers representing the edges of a rectangle in the order Left, Top, Right, Bottom. The values are in points and there are 72 points/inch.
So your original «media box» represents a PDF document having a size of 10 x 10 inch: {0.0, 720.0, 720.0, 0.0}
If you want to crop this to 9.5 x 9.5, then your «crop box» should be adjusted to: {0.0, 684.0, 684.0, 0.0}
But please keep in mind that I don’t work with Acrobat, so I cannot test it.
You should get what you want from this
tell application "Adobe Acrobat 7.0 Professional"
activate
tell active doc
tell page 1
set MB_Size to media box
-- Points to inch conversion with rounding
set MB_Height to my RoundDecimal((((item 2 of MB_Size) - (item 4 of MB_Size)) / 72), 3, to nearest)
set MB_Width to my RoundDecimal((((item 3 of MB_Size) - (item 1 of MB_Size)) / 72), 3, to nearest)
display dialog "Your media box is." & return & return & MB_Width & " inches wide" & return & MB_Height & " inches high" giving up after 6
-- Inch measure conveted to points for the math
set Crop_Amount to 0.25 * 72
set {L, T, R, B} to media box
set crop box to {L + Crop_Amount, T - Crop_Amount, R - Crop_Amount, B + Crop_Amount}
set CB_Size to crop box
-- 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)
display dialog "Your crop box is." & return & return & CB_Width & " inches wide" & return & CB_Height & " inches high" giving up after 6
end tell
end tell
end tell
--
on RoundDecimal(NumberToRound, DecimalPlace, RoundType)
set RoundFactor to 10 ^ DecimalPlace
NumberToRound * RoundFactor
round result rounding RoundType
result / RoundFactor
end RoundDecimal
Thanks for both the explanation of pdf space and the script. I’m certain that this will work perfectly, but I won’t have time to try it til tonight.