Estepp, Dan wrote:

>     float iWidth =
>         (float) ( (aImg.scaledWidth() /
>                    ( ( (aImg.getDpiX() == 0) ? 200 : aImg.getDpiX())))
>                  * 72);
>     float iHeight =
>         (float) ( (aImg.scaledHeight() /
>                    ( ( (aImg.getDpiY() == 0) ? 200 : aImg.getDpiY())))
>                  * 72);

OK, here you have a width and a height expressed in pt.
However: this value can be > 14,400
If this is the case, the next line doesn't make any sense:

>               nDocument = new Document(new Rectangle(iWidth, iHeight),
>                                        0, // left
>                                        0, // right
>                                        0, // top
>                                        0); // bottom

I mean: we have explained that iText takes values higher than
the ones that are allowed in PDF, that you should check yourself
if the PDF limitation are respected. Then why do you still create
a document using an width and height that might be wrong?
That's the first thing I don't understand about your code.

You should test if iWidth and/or iHeight > 14,400 before creating
the document object. For instance, if iWidth = 15,000 and iHeight
= 10,000, you should create a document with iWidth = 14,400 and
iHeight = 9,600. Then set the user unit to 1.0467 so that the
actual dimension of the documents are:
width = 14,400 * 1.0467 = 15,072.48
height = 9,600 * 1.0467 = 10,048.32
which is approximately the size we were looking for
(15,000 by 10,000). You can get a more correct result
if you don't round the number but use a more precise
value for 15,000 / 14,400. It's just some Math.

>               nPdfWriter =
>                   PdfWriter.getInstance(nDocument,
>                                         new FileOutputStream(nPdfFile));

I honestly don't understand the following line:

>               // nPdfWriter.setUserunit(( (img.getDpiX() == 0) ? 200 :
> img.getDpiX()));

What do you expect to happen? Please explain.
Have you read the explanation in chapter 3 of the book?
Incidentally that chapter is available for free.

>               aImg.scaleToFit(iWidth, iHeight);
>                 nDocument.add(aImg);

I haven't tested my answer, but I wrote this extra mail because
you got me all confused. Maybe you think that's frustrating for
you, but it is at least as frustrating for me. You must realize
that it's impossible to have a dialog with people who keep on
repeating the same question without clarifying why they don't
follow the advice that is given.
Please adapt your code according to what I write here; if it
doesn't work, we can continue talking. If you don't want to
follow the advice, you're on your own.

br,
Bruno

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to