Page 1 of 1

PDF creation lacks bounding box

Posted: 2011-06-16T07:40:19-07:00
by Ziggie
I am attempting to create text based PDF documents (simple, one line text files like this - which was created using Adobe Illustrator) using ImageMagick.

Unfortunately, there seems to be something wrong with the command I am using because I am not getting valid defined boxes in my PDFs when I check the output of the command (see this one). Acrobat doesn't complain about the lack of these boxes (it also cannot display them), but when I plug this file into other workflow tools, these files fail due to the lack of these boxes.

I am running on Ubuntu Linux running ImageMagick 6.5.7-8 and Ghostscript 8.71 from the command line. (Bash)

I don't think I'm googling the right terms, because I have so far found no useful hits (imagemagick bounding box, imagemagick art box, imagemagick create bounding box). I found lots of references to what could be a wealth of information in the -define properties, but haven't yet been able to discover what options are available to use. I did not find anything similar on this forum either. If I missed it, can someone please point me in the right direction?

Here is the command I am running to create the PDF:

Code: Select all

/usr/bin/convert -size 3000x150 xc:transparent -pointsize 12 -fill "#000000" -density 600x600 -gravity West -annotate 0x0 'Effective through November 30th' ~/testfile2.pdf
I've tried a few different variations with mixed results.
I added a -page option, which worked unless -size and -page were different. I would then get a blank white file.
Using only the -page option gives me a blank white pdf.
I tried using a blank file first (both at 1 px by 1 px and 1000 px by 1000 px) and super imposing the text on the resized document. That gave me two blank pages as an output. (the -size may will vary programatically eventually).
I did find -define pdf:use-cropbox=true to be valid, but it did not have the desired effect.
-define pdf:HiResBoundingBox =3000x150 gave me an error that image 3000x150 could not be found.

At this point, I'm at a loss as to what I can try next. Is what I'm trying to do even possible using ImageMagick?

I am getting PDFs out of ImageMagick - however they do not have the defining boxes that tells other programs how to use these files (and I am told are a fundamental part of the PDF).

Thank you for taking the time to read and consider this post. I debated between putting this here or in the Developers channel. If I chose wrong, please forgive me.

Re: PDF creation lacks bounding box

Posted: 2011-06-16T17:53:30-07:00
by anthony
NOTE: Imagemagick is a raster image processor. that is it generates an array of pixels.

For PDF files involving mostly text, IM is probably not the best tool (PDF images will be very large). As such Imagemagick may not be the right tool for you. If you don't mind large PDF's at fixed resolution (density), then by all means continue.


You may like to look at a vector image processing method as an alternative.

For example: many years ago I had good success creating postscript/PDF images of text, boxes, and arrows simple by writing 'FIG' files (as per the very old program "xfig") directly (the file format is very simple and well defined). These can then convert easily and directly to PDF.

Other possibilities is writing SVG files and then converting those.

Also if you are a Perl programmer, there are Perl modules to create PDF documents directly (check the CPAN archive). Similar modules are probably available for Python and Ruby languages.

As I have said in the past...
There are lots of ways to skin a cat, and what method you use depends
on what you want that skin for, and how messy you like the results!
-- Anthony Thyssen

Re: PDF creation lacks bounding box

Posted: 2011-06-21T13:20:51-07:00
by Ziggie
Thank you so much for your reply and your thoughts. I didn't think IM was the best tool for the job, it was just the one I had at hand.

We ended up using IM for this task, but in a very clunky way. This met our immediate need while we look for a better, less kludgey, long term solution.

We have now wrapped a shell script around Convert so it is still one command to call. This shell script generates a PNG file then converts it to PDF and somehow all of our other programs are happy with this arrangement.

I will look into creating Vector based files in the meantime. It certainly sounds like the right direction to go.

Thanks again.