/// <summary> /// Measures the widths of the columns within the given table. /// </summary> /// <returns>The table column widths.</returns> /// <param name="table">Table.</param> private static double[] MeasureTableColumns(string[,] table, PdfFont[] fonts) { var ret = new double[table.GetLength(0)]; for (int c = 0; c < ret.Rank; c++) { for (int r = 0; r < table.GetLength(c); r++) { var p = PdfTextEngine.MeasureString(table[r, c], fonts[c]); if (p.Width > ret[c]) { ret[c] = p.Width; } } } return(ret); }
public TextColumn(string[] data, PdfStringAppearanceOptions appearance) { this.data = data; this.appearance = appearance; for (int i = 0; i < data.Length; i++) { var size = PdfTextEngine.MeasureString(data[i], appearance.Font); if (size.Height > rowHeight) { rowHeight = size.Height; } if (size.Width > columnWidth) { columnWidth = size.Width; } } }
/// <summary> /// Draws the header of the screenshot report. /// </summary> private static void DrawHeader(ScreenshotReport report, PdfPage page, PdfStandardRectangle bounds, PdfStandardFont title, PdfStandardFont subtitle) { var layout = NewLayout(PdfStringHorizontalAlign.Center); layout.Height = bounds.Height; layout.Width = bounds.Width; var pen = NewPen(); var g = page.Graphics; var l = bounds.LLX; var r = bounds.URX; layout.X = l; layout.Y = bounds.LLY; g.DrawString(report.title, NewAppearance(title), layout); layout.Y += PdfTextEngine.GetStringHeight("Dg", title, layout.Width); g.DrawString(report.subtitle, NewAppearance(subtitle), layout); layout.Y += PdfTextEngine.GetStringHeight("Dg", title, layout.Width); g.DrawLine(pen, l, layout.Y - 1, r, layout.Y - 1); }