The result is correct as the alignment is made by the leading. What you
want is to align by the ascent. You can get the ascent with
BaseFont.getFontProperties(). 

> -----Original Message-----
> From: Andreas Meyer [mailto:[EMAIL PROTECTED] 
> Sent: Monday, April 04, 2005 5:53 PM
> To: Paulo Soares
> Cc: [email protected]
> Subject: Re: RE: [iText-questions] middle align background 
> image with text
> 
> 
> As mentioned below the text "PARTY" is marked with 
> "myChunk.setGenericTag()"
> and "public void onGenericTag()" now contains these lines: 
> 
> Image img = Image.getInstance("kategorie_bg.gif");
>                       
> img.scalePercent(24); // 300dpi
>                       
> img.setAbsolutePosition(rect.left(), rect.bottom() - 
> ((img.scaledHeight() -
> rect.height()) / 2));
>             
> writer.getDirectContentUnder().addImage(img);
> 
> I have expected that "rect.bottom() - ((img.scaledHeight() - 
> rect.height()) /
> 2)" would (nearly) middle align the background image as shown 
> in the attached gif.
> 
> Can you please tell me whats wrong ?
> 
> 
> > What am I supposed to see? Post working code and the result that you
> > expect. 
> > 
> > > -----Original Message-----
> > > From: Andreas Meyer [mailto:[EMAIL PROTECTED] 
> > > Sent: Monday, April 04, 2005 2:59 AM
> > > To: Paulo Soares
> > > Cc: [email protected]
> > > Subject: Re: RE: RE: [iText-questions] middle align 
> > > background image with text
> > > 
> > > Scaling is 24% and I get the same unexpected result with both 
> > > approaches
> > > (enlarged part of screenshot attached, please only pay 
> > > attention to vertical
> > > alignment).
> > > 
> > > 
> > > > 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 ?
> 


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to