On 1/11/2011 12:40, Giampaolo Capelli wrote:
> But since Acrobat Reader is able to properly render my pdf file,
> I guess there should be some way to get the data I need.

Why would Adobe Acrobat or Adobe Reader need to know the width and the 
height of the Form XObject? The bounding box isn't drawn, so it isn't 
required if you want to draw a Form XObject. If you see a rectangle, 
it's not defined by the bounding box. If you see a rectangle, you'll 
find an "re" operator or a sequence of "m" and "l" operators in the 
stream containing the PDF syntax.

NOTE: if a bounding box was defined, this bounding box needn't coincide 
with a visual bounding box that is drawn in the syntax stream.

> Do I need to use a third party library to parse that pdf syntax,

iText can perfectly parse PDF syntax, but you're talking about getting 
information that isn't present in the PDF. My point was: if the 
information isn't present, you shouldn't expect any software to be able 
to get it for you.

> or to render the images and calculate myself their attributes?

I assume that you're NOT taking about Image XObjects; you're talking 
about Form XObjects. Form XObjects aren't images, so please refrain from 
saying "images" in this context. You're talking about paths, shapes and 
text that are defined using PDF syntax. These aren't images!

Let me try to explain this as simple as possible:

1. You have a Form XObject, NOT an image. Please don't confuse people by 
telling them you want the width and the height of an image when in fact 
you need the bounding box of a Form XObject. If you don't phrase your 
question correctly, you shouldn't expect a correct answer.
2. Normally a Form XObject SHOULD HAVE a BBox entry. As you're not 
providing any PDF sample, we can't check if there a bounding box was 
defined. We assume that your allegation that the bounding box is missing 
is correct. Note that the bounding box doesn't always correspond exactly 
with the minimum rectangle that encloses the paths, shapes and text that 
are drawn in the Form XObject (see the NOTE above).
3. We assume that you want to get the minimum rectangle that encloses 
the paths, shapes and text drawn in the Form XObject. For text, this is 
easy: there's an example in the book that explains how to do it. For 
paths and shapes it's more complex. You need to adapt the parser 
provided by iText so that you keep track of all the coordinates and all 
the transformations of the graphics state. This is doable if you have 
straight lines, but it's plenty of work. As soon as Bézier curves are 
involved, you'll be facing even more development work.

If I understood your question correctly, if you want to find out the 
width and the height of a Form XObject for which no BBox was defined, 
then you either should do a lot of development, or you should give up 
hope because you won't find any API, tool or application that will find 
this BBox for you.

------------------------------------------------------------------------------
RSA® Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to