public override void DrawItem(PdfWriter pdfWriter, ICSharpCode.Reports.Core.Exporter.ExportRenderer.PdfUnitConverter converter) { if (pdfWriter == null) { throw new ArgumentNullException("pdfWriter"); } if (converter == null) { throw new ArgumentNullException("converter"); } base.DrawItem(pdfWriter, converter); iTextSharp.text.Font font = null; if (this.StyleDecorator.Font.Unit == GraphicsUnit.Point) { font = FontFactory.GetFont(this.StyleDecorator.Font.FontFamily.Name, BaseFont.IDENTITY_H, this.StyleDecorator.Font.Size, (int)this.StyleDecorator.Font.Style, this.StyleDecorator.PdfForeColor); } else { font = FontFactory.GetFont(this.StyleDecorator.Font.FontFamily.Name, BaseFont.IDENTITY_H, UnitConverter.FromPixel(this.StyleDecorator.Font.Size).Point, (int)this.StyleDecorator.Font.Style, this.StyleDecorator.PdfForeColor); } // // http://www.google.de/search?hl=de&q=itextsharp+%2B+measure+text&start=10&sa=N // http://www.mikesdotnetting.com/Article/82/iTextSharp-Adding-Text-with-Chunks-Phrases-and-Paragraphs // http://www.mikesdotnetting.com/Category/20 // itextsharp + columntext + textheight //itextsharp + columntext + rectangle //itextsharp + simulate //http://www.mail-archive.com/[email protected]/msg04747.html base.Decorate(); PdfContentByte contentByte = base.PdfWriter.DirectContent; iTextSharp.text.Rectangle r = base.ConvertToPdfRectangle(); ColumnText columnText = new ColumnText(contentByte); PdfFormat pdfFormat = new PdfFormat(this.StyleDecorator, font); columnText.SetSimpleColumn(r.Left, r.Top, r.Left + r.Width, r.Height, pdfFormat.Leading, pdfFormat.Alignment); // int a = Convert.ToInt16((r.Height/font.Size) + 1); // columnText.SetSimpleColumn(r.Left, r.Top , r.Left + r.Width,r.Height,a,pdfFormat.Alignment); string formated = StandardFormatter.FormatOutput(this.text, this.StyleDecorator.FormatString, this.StyleDecorator.DataType, String.Empty); Chunk chunk = new Chunk(formated, font); columnText.AddText(chunk); columnText.Go(); int i = columnText.LinesWritten; if (i > 1) { Console.WriteLine("{0} - {1}", i, this.text); Console.WriteLine("dif {0}", r.Height / font.Size); } }
public override void DrawItem(PdfWriter pdfWriter, ICSharpCode.Reports.Core.Exporter.ExportRenderer.PdfUnitConverter converter) { if (pdfWriter == null) { throw new ArgumentNullException("pdfWriter"); } if (converter == null) { throw new ArgumentNullException("converter"); } base.DrawItem(pdfWriter,converter); iTextSharp.text.Font font = null; if (this.StyleDecorator.Font.Unit == GraphicsUnit.Point) { font = FontFactory.GetFont(this.StyleDecorator.Font.FontFamily.Name, BaseFont.IDENTITY_H, this.StyleDecorator.Font.Size, (int)this.StyleDecorator.Font.Style, this.StyleDecorator.PdfForeColor); } else { font = FontFactory.GetFont(this.StyleDecorator.Font.FontFamily.Name, BaseFont.IDENTITY_H, UnitConverter.FromPixel(this.StyleDecorator.Font.Size).Point, (int)this.StyleDecorator.Font.Style, this.StyleDecorator.PdfForeColor); } // // http://www.google.de/search?hl=de&q=itextsharp+%2B+measure+text&start=10&sa=N // http://www.mikesdotnetting.com/Article/82/iTextSharp-Adding-Text-with-Chunks-Phrases-and-Paragraphs // http://www.mikesdotnetting.com/Category/20 // itextsharp + columntext + textheight //itextsharp + columntext + rectangle //itextsharp + simulate //http://www.mail-archive.com/[email protected]/msg04747.html base.Decorate(); PdfContentByte contentByte = base.PdfWriter.DirectContent; iTextSharp.text.Rectangle r = base.ConvertToPdfRectangle(); ColumnText columnText = new ColumnText(contentByte); PdfFormat pdfFormat = new PdfFormat(this.StyleDecorator,font); columnText.SetSimpleColumn(r.Left, r.Top , r.Left + r.Width,r.Height,pdfFormat.Leading,pdfFormat.Alignment); // int a = Convert.ToInt16((r.Height/font.Size) + 1); // columnText.SetSimpleColumn(r.Left, r.Top , r.Left + r.Width,r.Height,a,pdfFormat.Alignment); string formated = StandardFormatter.FormatOutput(this.text,this.StyleDecorator.FormatString, this.StyleDecorator.DataType,String.Empty); Chunk chunk = new Chunk(formated,font); columnText.AddText(chunk); columnText.Go(); int i = columnText.LinesWritten; if (i > 1) { Console.WriteLine("{0} - {1}",i,this.text); Console.WriteLine("dif {0}",r.Height/font.Size); } }