public void Row(List <PDFColumn> Columns) { double line_height = getLineHeight(Columns); if (OutOfPage(line_height)) { AddPage(); } foreach (var item in Columns) { double line_width = getLineWidth(item.ColumnSize); double cursorX = getCursorPosition(item.ColumnNumber); PDFStyle sty = getStyle(item.StyleName); if (sty.LineSpacing > 0) { cursor.Y += sty.LineSpacing; } // Borders if (sty.Borders != null) { XPen pen = new XPen(XColors.Black, 0); if (sty.Borders.Top) { graph.DrawLine(pen, new XPoint(cursorX, cursor.Y), new XPoint(cursorX + line_width, cursor.Y)); } if (sty.Borders.Left) { graph.DrawLine(pen, new XPoint(cursorX, cursor.Y), new XPoint(cursorX, cursor.Y + sty.LineHeight)); } if (sty.Borders.Bottom) { graph.DrawLine(pen, new XPoint(cursorX, cursor.Y + sty.LineHeight), new XPoint(cursorX + line_width, cursor.Y + sty.LineHeight)); } if (sty.Borders.Right) { graph.DrawLine(pen, new XPoint(cursorX + line_width, cursor.Y), new XPoint(cursorX + line_width, cursor.Y + sty.LineHeight)); } } graph.DrawString( item.Text, sty.Font, XBrushes.Black, new XRect(cursorX + PADDING, cursor.Y + PADDING, line_width - PADDING * 2, sty.LineHeight - PADDING * 2), sty.Center ? XStringFormats.TopCenter : XStringFormats.TopLeft); } cursor.Y += (int)line_height; }
private double getLineHeight(List <PDFColumn> Columns) { double line_height = 0; foreach (var item in Columns) { PDFStyle sty = getStyle(item.StyleName); if (sty.LineHeight > line_height) { line_height = sty.LineHeight; } } return(line_height); }