> -----Original Message-----
> From: fuggly [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, April 29, 2004 10:08 PM
> To: Paulo Soares; [EMAIL PROTECTED]
> Subject: Re[2]: [iText-questions] Clipping, Images and 
> rounded rectangle
> 
> > Show me your code.
> 
> The code basically does this:
> 
>         content.roundRectangle((float) 
> nativeToDevice(getX()), (float) nativeToDevice(getY()), 
> (float) nativeToDevice(getWidth()), (float) 
> nativeToDevice(-getHeight()), (float) nativeToDevice(smallest));
>         content.setLineWidth((float) nativeToDevice(borderWidth));
>         content.stroke();
> 
> content is a Document.getDirectContent() PdfContentByte object.
> In the execution, the paramters looks like this:
> 
> content.roundRectangle(291.68503, 776.5795, 14.173228, -15.703937,
> 3.3543307);
> 
> The - at the height comes because my engine calculates everything from
> top to bottom, but the coordinate system in iText (or PDF) is from
> bottom to top, so I write a rectangle backwards.
> 
> The line width comes to 
> 
> 0.8503937
> 

The width and height of the rounded rectangle must be all positive and
that's a bug. In the next release I'll normalize it so that it works
correctly even with negative values.

> 
> As for the picture problem.. well.. I don't think that this 
> is a problem
> of iText at all (except the file size, but that comes down to be my
> problem as well I guess). The code I have right now, does this:
> 
>   // Convert the image that comes in whatever format possible to PNG..
>     try { imageConverter.convert(object, "png"); }
>     catch (IOException io) {
>       io.printStackTrace();
>       return;
>     }
>     
>    // get the AWT image container in PNG format
>     java.awt.Image awtImage = (java.awt.Image)
>     imageConverter.getObject();
> 
>   // get a PDF image instance of this AWT image
>     Image pdfImage;
>     try { pdfImage  = Image.getInstance(awtImage, null); }
>     catch (BadElementException be) {
>       be.printStackTrace();
>       return;
>     }
>     catch (IOException io) {
>       io.printStackTrace();
>       return;
>     }
> 
>   // If its a picture (and not a barcode...)
>     if (object.getOrigin() instanceof Picture) {
>       // write the background and border styles...
>       decorateField(outputContainer, object);
>       Dimension dimension = (Dimension) 
> object.extensions().get(Dimension.class);
>       switch (((Picture) object.getOrigin()).getSizeMode()) {
>         case Picture.ORIGINAL:
>           break;
>         case Picture.STRETCH:
>           // Stretch the picture to fill the dimension of the original
>           // container...
>           pdfImage.scaleAbsolute((float) 
> nativeToDevice(width), (float) nativeToDevice(height));
> ...
>     // Now set the picture to the position set by the report engine...
>     pdfImage.setAbsolutePosition((float) nativeToDevice(pX), (float)
>     nativeToDevice(pY - height));
>     
>     // and add it to the PDF..
>     try { content.addImage(pdfImage); }
>     catch (DocumentException de) { de.printStackTrace(); }
> 
> 
> Thats it. I did not yet implement clipping, because I don't 
> know how to
> do it yet, I'm still experimenting with java.awt.Image.setClip(), but
> that has nothing to do with iText.
> 
> I dont' know if my problem is something that has already been answered
> many times before, as I did not search into the forum that 
> deeply, but I
> didn't see anything. If this is the typical "iText newbie didn't RTFM"
> question, I would like to apologize in advance, and I will 
> sadly hang my
> head to shame and return to the tutorials and FAW's, but I 
> couldn't find
> it, so.. :-)
> 

AWT images are not intrinsically bigger than PNG but in iText are always
converted to RGB, hence the size. There are also some simplifications
regarding transparency that can cause some unexpected side effects. If
you want the biggest size efficiency do all the manipulations and
clipping with jai, save the image to png and read it into iText with
Image.getInstance().

Best Regards,
Paulo Soares


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id149&alloc_id�66&op=click
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to