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 ?
<<attachment: backgroundimage_expected.gif>>
