writer.getDirectContentUnder().addImage(img, img.scaledWidth(), 0, 0,
img.scaledHeight(),
rect.left() + rect.width()/2 - img.scaledWidth()/2,
rect.bottom() + rect.height()/2 - img.scaledHeight()/2);

It may not work if scaling is not 100% or with rotation. A better way
is:

img.setAbsolutePosition(rect.left() + rect.width()/2 -
img.scaledWidth()/2,
rect.bottom() + rect.height()/2 - img.scaledHeight()/2);
writer.getDirectContentUnder().addImage(img);

(warning: code not tested)

> -----Original Message-----
> From: Andreas Meyer [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, March 31, 2005 11:18 AM
> To: Paulo Soares
> Subject: Re: RE: [iText-questions] middle align background 
> image with text
> 
> 
> The text is in the rectangle.
> 
> writer.getDirectContentUnder().addImage() is part of "public void
> onGenericTag()" and the text is marked with 
> "myChunk.setGenericTag()" ...
> 
> Thanks for your help !
> 
> > Where is the text? 
> > 
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED] 
> > > [mailto:[EMAIL PROTECTED] On 
> > > Behalf Of Andreas Meyer
> > > Sent: Tuesday, March 29, 2005 4:18 AM
> > > To: [email protected]
> > > Subject: [iText-questions] middle align background image with text
> > > 
> > > Hi,
> > > 
> > > I would like to align text precisely in the middle of a 
> > > background image. I have
> > > tried it this way, but with no luck:
> > > 
> > > writer.getDirectContentUnder().addImage(img, 
> img.scaledWidth(), 0, 0,
> > > img.scaledHeight(), rect.left(), rect.bottom() - 
> > > ((img.scaledHeight() -
> > > rect.height()) / 2));
> > > 
> > > Can you please tell me whats wrong ?
> 


-------------------------------------------------------
This SF.net email is sponsored by Demarc:
A global provider of Threat Management Solutions.
Download our HomeAdmin security software for free today!
http://www.demarc.com/Info/Sentarus/hamr30
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to