Page 1 of 1

PDF: use-trimbox not working

Posted: 2009-03-09T04:52:51-07:00
by blahor
Hi again,

I'm trying to convert pdfs and automatically crop the area outside the trimbox, but it's not working as expected.
My command (ImageMagick 6.2.4 02/10/07 Q16):

Code: Select all

convert -define pdf:use-trimbox=true -density 300 foo.pdf -resize 600 bar.jpg
If i set -define pdf:use-trimbox=true nothing happens, the resulting image is showing the whole pdf:
result


So I copied the trim value to crop inside the pdf and tried:

Code: Select all

convert -define pdf:use-cropbox=true -density 300 foo.pdf -resize 600 bar.jpg
This time the image is cut right, but it's still using the original page size resulting in a big white border:
result

So basically I have two questions:
* how do i get rid off the white border when using cropbox? did i miss a +repage or something?
* why doesn't use-trimbox work?

EDIT:

seems like -trim +repage will remove the white borders:

Code: Select all

 convert -define pdf:use-cropbox=true -density 300 -trim +repage foo.pdf -resize 600x bar.jpg
But I'm afraid this will remove parts of images which are starting white inside the trimbox.

Re: PDF: use-trimbox not working

Posted: 2009-03-10T02:15:07-07:00
by blahor
I've solved the problem with a little workaround:

I made a perl script that checks the pdf file for a TrimBox and writes the trimbox values to the CropBox property if necessary. Then i use ghostscript to generate a new cropped pdf (gs -sDEVICE=pdfwrite -dUseCropBox -sOutputFile=out.pdf -_ < in.pdf).
The cropped pdf is used for further conversions with IM.

LMK if there's an easier way...

Re: PDF: use-trimbox not working

Posted: 2010-03-19T08:15:20-07:00
by wisepeace
blahor wrote:I've solved the problem with a little workaround:

I made a perl script that checks the pdf file for a TrimBox and writes the trimbox values to the CropBox property if necessary. Then i use ghostscript to generate a new cropped pdf (gs -sDEVICE=pdfwrite -dUseCropBox -sOutputFile=out.pdf -_ < in.pdf).
The cropped pdf is used for further conversions with IM.

LMK if there's an easier way...
Are there any ImageMagick admins that have a better or similar solution for this?

Re: PDF: use-trimbox not working

Posted: 2011-01-17T04:46:53-07:00
by basstradamus
Does anybody knows why pdf:use-trimbox=true doesn't work at all???

Re: PDF: use-trimbox not working

Posted: 2011-01-17T19:37:03-07:00
by anthony
If it is not working, you should report a bug in the bugs area. But be sure it is definatally wrong, and include examples files.