Peter Forstmeier wrote:
> Hi List,
> i would like to add some variable length Text at a give location and a given
> Height and Width:
> 
> PdfContentByte cb = base.PdfWriter.DirectContent;
> 
> iTextSharp.text.Rectangle r = base.ConvertToPdfRectangle();
> 
> ColumnText ct = new ColumnText(cb);
> 
> PdfFormat pdfFormat = new PdfFormat(this.StyleDecorator,font);
> 
> ct.SetSimpleColumn(r.Left, r.Top , r.Left +
> r.Width,r.Height,pdfFormat.Leading,pdfFormat.Alignment);
>                       
> string formated =
> StandardFormatter.FormatOutput(this.text,this.StyleDecorator.FormatString,
>       
> this.StyleDecorator.DataType,String.Empty);
> 
> hunk chk = new Chunk(formated,font);
> ct.AddText(chk);
> ct.Go();
> 
> Where pdfFormat.Leading is set to FontSize.Height andf the Rextangle is set
> correctly.
> 
> The width of the rectangle is used correct. Means text is wrapped correctly.
> 
> Problem: It seems that ColumnText is ignoring the Height of the given
> Rectangle.
> If the text is longer, the output is drawn over the rectangle boundaries.
> 
> Is there any chance to let ColumnText cut the original text to fit inside
> the given Rectangle.
> 
> 
> Any idea?????

Well, ColumnText behaves exactly the way you need it to behave,
but I think you've made a mistake when defining the coordinates:

 > ct.SetSimpleColumn(r.Left, r.Top , r.Left +
 > r.Width,r.Top - r.Height,pdfFormat.Leading,pdfFormat.Alignment);

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to