2
votes

I have a PDF-file with the following dimensions;

mediabox: 23.08 x 31.78 cm

cropbox: 23.08 x 31.78 cm

trimbox: 21 x 29.7 cm

I'm using ImageMagick to try and get the trimbox value using Imagemagick's trimbox function.

identify -format "%[fx:(w/72)*2.54]x%[fx:(h/72)*2.54]" -define pdf:use-trimbox=true foo.pdf

This line of code gives me 23.08x31.78 cm which is the size of the media/crop-box. If I check the values of these boxes with Adobe Acrobat Reader I get the values I just posted in the top of this very post. Acrobat Reader/Photoshop/In Design tells me that the trimbox is 21x29.7 cm but ImageMagick just doesn't read the same value.

My guess is that ImageMagick can't interpret the trimbox correctly and then returns the cropbox values instead.

Does anyone know how to get the trimbox value from a correctly formated PDF-file or did anyone have the same problem?

Imagemagick states that this function should work, but some of the forums threads beg to differ.

2

2 Answers

3
votes
convert -resize 50% -define pdf:use-cropbox=true 1.pdf 1.jpg
0
votes

You can always find it as clear text within the page dictionary:

alt text http://sourceforge.net/apps/wordpress/moonshiner/nfs/project/m/mo/moonshiner/uploads/2009/05/pdfboxdata.png

If you need it just in one case, a hex editor will probably suffice. If it's a recurring thing you want to accomplish programatically, you might want to use a PDF parsing framework (a free example would be PoDoFo, but there's lots of others, too).