/// <summary> /// Creates an 'Inner Table' with no header. Instead Labels and their content are displayed side by side. /// Labels are in 'Bold' and descriptions are in normal form. /// | || | /// E.g. | My Label (in bold) || My Description | /// | || | /// </summary> /// <param name="table">table</param> /// <param name="label">label</param> /// <param name="columnWidths">columnWidths</param> /// <param name="description">description</param> /// <param name="firstSectionText">firstSectionText</param> /// <param name="underlineText">underlineText</param> /// <param name="secondSectionText">secondSectionText</param> /// <param name="padding">padding</param> public void CreateInnerTableLabelValueRow( Generator.Table table, string columnWidths, string description, string label = "", string firstSectionText = "", string underlineText = "", string secondSectionText = "", Generator.MarginInfo padding = null) { var nestedTable = new Generator.Table { ColumnWidths = columnWidths, DefaultCellTextInfo = { FontName = Properties.Resources.ArialFont, FontSize = DefaultInnerBodyFontSize }, DefaultCellBorder = new Generator.BorderInfo((int)Generator.BorderSide.All, DefaultBorderSize), DefaultCellPadding = DefaultInnerPadding, BackgroundColor = new Generator.Color(Properties.Resources.InnerTableColor) }; // add descriptions var tableRow = nestedTable.Rows.Add(); if (!string.IsNullOrEmpty(underlineText) && !string.IsNullOrEmpty(firstSectionText) && !string.IsNullOrEmpty(secondSectionText)) { var labelSectionText = new Generator.Text(Section); var labelSegmentOne = new Segment(labelSectionText) { Content = firstSectionText, TextInfo = { FontName = Properties.Resources.ArialFont, FontSize = DefaultInnerBodyFontSize } }; labelSegmentOne.TextInfo.IsTrueTypeFontBold = true; labelSectionText.Segments.Add(labelSegmentOne); var labelSegmentTwo = new Segment(labelSectionText) { Content = underlineText, TextInfo = { FontName = Properties.Resources.ArialFont, FontSize = DefaultInnerBodyFontSize, IsUnderline = true, IsTrueTypeFontBold = true, } }; labelSectionText.Segments.Add(labelSegmentTwo); var labelSegmentThree = new Segment(labelSectionText) { Content = secondSectionText, TextInfo = { FontName = Properties.Resources.ArialFont, FontSize = DefaultInnerBodyFontSize, IsTrueTypeFontBold = true } }; labelSectionText.Segments.Add(labelSegmentThree); var tableRowCell = tableRow.Cells.Add(); tableRowCell.Paragraphs.Add(labelSectionText); } else { var labelCell = tableRow.Cells.Add(label); labelCell.DefaultCellTextInfo.IsTrueTypeFontBold = true; } var descriptionCell = tableRow.Cells.Add(description); descriptionCell.VerticalAlignment = VerticalAlignmentType.Center; // add content back into parent cell var parentRow = table.Rows.Add(); var parentCell = parentRow.Cells.Add(); parentCell.ColumnsSpan = 2; if (padding != null) { parentCell.Padding = padding; } parentCell.Paragraphs.Add(nestedTable); }
/// <summary> /// Create a sub heading row. User must specify <see cref="subHeadingText"/> /// and a <see cref="Generator.Table"/> to add the row to. /// If the user specifies <see cref="isFullPageText"/> the sub heading will be rendered /// across the entire page and not to the default of 'three' columns (four is total). /// </summary> /// <param name="subHeadingText">subHeadingText</param> /// <param name="table">table</param> /// <param name="margins">margins</param> /// <param name="isFullPageText">isFullPageText</param> public void CreateSubHeadingRow( string subHeadingText, Generator.Table table, Generator.MarginInfo margins = null, bool isFullPageText = false) { var subHeadingTable = !isFullPageText ? table : new Generator.Table { ColumnWidths = Properties.Resources.DefaultFullWidth }; var row = subHeadingTable.Rows.Add(); var cell = row.Cells.Add(string.Empty); cell.ColumnsSpan = DefaultHeaderColumnSpan; cell.Padding = DefaultSubHeadingPadding; var paragraph = new Generator.Text(subHeadingText) { TextInfo = { FontName = Properties.Resources.ArialFont, FontSize = int.Parse(Properties.Resources.HeadingTwoFontSize), Color = new Generator.Color(Properties.Resources.BlackColor), IsTrueTypeFontBold = true } }; if (margins != null) paragraph.Margin = margins; cell.Paragraphs.Add(paragraph); }
/// <summary> /// Create <see cref="Text"/> and inject it into a <see cref="Generator.Cell"/>. /// <see cref="Generator.Row"/> provides additional information necessary to format /// the text. /// </summary> /// <param name="row">row</param> /// <param name="cell">cell</param> /// <param name="content">content</param> /// <param name="fontName">fontName</param> private static void CreateCellText(Generator.Row row, Generator.Cell cell, string content, string fontName = "") { var cellText = new Generator.Text(content) { TextInfo = new TextInfo { FontName = !string.IsNullOrEmpty(fontName) ? fontName : row.DefaultCellTextInfo.FontName, FontSize = row.DefaultCellTextInfo.FontSize, IsUnicode = true } }; cell.Paragraphs.Add(cellText); }