private static void CreateSectionOneExample001(PdfBuilder pdfBuilder, MarginInfo parentPadding) { const string detailsColumnWidths = "140 310"; const bool boolValue = true; // Create Outer Table var exampleOuterTable = pdfBuilder.CreateOuterTable( detailsColumnWidths, Resources.ArialFont, PdfBuilder.DefaultHeadingTwoFontSize, parentPadding, keepContentTogether: true); // Create outer table heading pdfBuilder.CreateOuterTableRowHeading( exampleOuterTable, "Example Heading"); // insert blank row pdfBuilder.BlankRow(exampleOuterTable); // Create details var exampleLabelTextBox01 = exampleOuterTable.Rows.Add(); pdfBuilder.CreateOuterTableRowCells( exampleLabelTextBox01, "Example 01 (label-textbox)", "Description of example 01", padding: PdfBuilder.DefaultSubHeadingBottomPadding); var exampleLabelTextBox02 = exampleOuterTable.Rows.Add(); pdfBuilder.CreateOuterTableRowCells( exampleLabelTextBox02, "Example 02 (label-textbox)", "Description of example 02", padding: PdfBuilder.DefaultSubHeadingBottomPadding); var exampleLabelTextBox03 = exampleOuterTable.Rows.Add(); pdfBuilder.CreateOuterTableRowCells( exampleLabelTextBox03, "Example 03 (label-textbox)", "Description of example 03", padding: PdfBuilder.DefaultSubHeadingBottomPadding); var exampleLabelTextBox04 = exampleOuterTable.Rows.Add(); pdfBuilder.CreateOuterTableRowCells( exampleLabelTextBox04, "Example 04 (label-textbox)", "Description of example 04", padding: PdfBuilder.DefaultSubHeadingBottomPadding); var exampleLabelTextBox05 = exampleOuterTable.Rows.Add(); pdfBuilder.CreateOuterTableRowCells( exampleLabelTextBox05, "Example 05 (label-textbox)", "Description of example 05", padding: PdfBuilder.DefaultSubHeadingBottomPadding); var capitalOnlyRow = exampleOuterTable.Rows.Add(); pdfBuilder.CreateOuterTableRowCells( capitalOnlyRow, "Example Name 06 (from bool as yes/no value)", pdfBuilder.CreateYesNoValue(boolValue), padding: PdfBuilder.DefaultSubHeadingBottomPadding); // project description pdfBuilder.CreateTextAreaCell( exampleOuterTable.ColumnWidths, "Example 07 (textarea)", "Description of example 07", Resources.TextAreaColumnWidths); pdfBuilder.BlankRow(); }
private static void CreateSectionFiveExample001(PdfBuilder pdfBuilder, MarginInfo parentPadding) { var secionFiveExampleTable = pdfBuilder.CreateOuterTable( "140 310", Resources.ArialFont, PdfBuilder.DefaultHeadingTwoFontSize, parentPadding, keepContentTogether: true); // create table row heading pdfBuilder.CreateOuterTableRowHeading( secionFiveExampleTable, "Example Section 5 Heading"); pdfBuilder.BlankRow(secionFiveExampleTable); // Create dates var exampleItem01Row = secionFiveExampleTable.Rows.Add(); pdfBuilder.CreateOuterTableRowCells( exampleItem01Row, "Example item 01", DateTime.Now.ToShortDateString(), padding: PdfBuilder.DefaultSubHeadingBottomPadding); var exampleItem02Row = secionFiveExampleTable.Rows.Add(); pdfBuilder.CreateOuterTableRowCells( exampleItem02Row, "Example item 02", "example info", padding: PdfBuilder.DefaultSubHeadingBottomPadding); var exampleItem03Row = secionFiveExampleTable.Rows.Add(); pdfBuilder.CreateOuterTableRowCells( exampleItem03Row, "Example item 03", "example info", padding: PdfBuilder.DefaultSubHeadingBottomPadding); var exampleItem04Row = secionFiveExampleTable.Rows.Add(); pdfBuilder.CreateOuterTableRowCells( exampleItem04Row, "Example item 04", "example info", padding: PdfBuilder.DefaultSubHeadingBottomPadding); pdfBuilder.BlankRow(secionFiveExampleTable); // create an overly complex arrangement of data and values to demonstrate the flexibility of the aspose pdf builder. var orderedNumbers = new[] { "0001", "0002", "0003" }; var examplePairsAsGroup = new List<KeyValuePair<string, decimal>> { new KeyValuePair<string, decimal>(orderedNumbers[0], 10000), new KeyValuePair<string, decimal>(orderedNumbers[0], 10000), new KeyValuePair<string, decimal>(orderedNumbers[0], 10000), new KeyValuePair<string, decimal>(orderedNumbers[1], 20000), new KeyValuePair<string, decimal>(orderedNumbers[1], 20000), new KeyValuePair<string, decimal>(orderedNumbers[1], 20000), new KeyValuePair<string, decimal>(orderedNumbers[2], 30000), new KeyValuePair<string, decimal>(orderedNumbers[2], 30000), new KeyValuePair<string, decimal>(orderedNumbers[2], 30000) }.OrderBy(x => x.Key) .GroupBy(x => x.Key) .ToArray(); // calculate totals - terrible example... var orderedNumbers0001 = examplePairsAsGroup.SelectMany(x => x).Where(x => x.Key == orderedNumbers[0]).ToArray(); var orderedNumbers0002 = examplePairsAsGroup.SelectMany(x => x).Where(x => x.Key == orderedNumbers[1]).ToArray(); var orderedNumbers0003 = examplePairsAsGroup.SelectMany(x => x).Where(x => x.Key == orderedNumbers[2]).ToArray(); var exampleTotalsAsGroup = new List<KeyValuePair<string, decimal>> { new KeyValuePair<string, decimal>(orderedNumbers[0], orderedNumbers0001[0].Value + orderedNumbers0002[0].Value + orderedNumbers0003[0].Value), new KeyValuePair<string, decimal>(orderedNumbers[1], orderedNumbers0001[1].Value + orderedNumbers0002[1].Value + orderedNumbers0003[1].Value), new KeyValuePair<string, decimal>(orderedNumbers[2], orderedNumbers0001[2].Value + orderedNumbers0002[2].Value + orderedNumbers0003[2].Value) }.OrderBy(x => x.Key) .GroupBy(x => x.Key) .ToArray(); var useWidths = "53 80 79 79 80 79"; // remember - a user can specify less or more columns and pass them into CreateInnerTable. // Create an inner table var exampleInnerTable = pdfBuilder.CreateInnerTable(useWidths, secionFiveExampleTable); // Create Header Inner Table row var exampleInnerHeaderRow = pdfBuilder.CreateInnerTableRow(exampleInnerTable, parentPadding); // Create Header Cell Titles var titles = new List<HeaderCell> { new HeaderCell { Content = "Side Content Name" } }; var additionalNames = new [] { "example 01", "example 02", "example 03" }.GroupBy(x => x).ToArray(); titles.AddRange(additionalNames.Select(name => new HeaderCell { Content = "ex name " + name.Key })); titles.Add(new HeaderCell { Content = "Total" }); pdfBuilder.CreateInnerTableHeaderCells(exampleInnerHeaderRow, titles.ToArray()); // Display example pairs by their ordered numbers foreach (var epag in examplePairsAsGroup) { var cellContentByFy = new List<DisplayCell> { new DisplayCell { Content = epag.Key, IsDate = true } }; cellContentByFy.AddRange(epag.Select(x => new DisplayCell { Content = x.Value.ToString("C"), IsCurrency = true }).ToArray()); cellContentByFy.Add(new DisplayCell { Content = epag.Sum(x => x.Value).ToString("C"), IsCurrency = true }); var itemRow = pdfBuilder.CreateInnerTableRow(exampleInnerTable, parentPadding); pdfBuilder.CreateInnerTableItemCells( itemRow, cellContent: cellContentByFy.ToArray()); } // Display Totals var cellContentTotals = new List<DisplayCell> { new DisplayCell { Content = "Totals", IsHeader = true } }; cellContentTotals.AddRange(exampleTotalsAsGroup.Select(x => new DisplayCell { Content = x.Sum(sum => sum.Value).ToString("C"), IsTotal = true, IsCurrency = true }).ToArray()); cellContentTotals.Add(new DisplayCell { Content = exampleTotalsAsGroup.Sum(sum => sum.Sum(x => x.Value)).ToString("C"), IsTotal = true, IsCurrency = true }); var projectCostCentreTotalRow = pdfBuilder.CreateInnerTableRow(exampleInnerTable, PdfBuilder.DefaultOuterPadding); pdfBuilder.CreateInnerTableItemCells( projectCostCentreTotalRow, cellContent: cellContentTotals.ToArray()); pdfBuilder.BlankRow(); }