Hi all,
I'm using RadPdfProcessing for ASP.NET MVC to create pdf template for financial documents. Sometimes content of some tables can be various length. In this case I'd like to move lower blocks/tables to a new page and generate pdf document with two pages. I'm using RadFixedDocument and FixedContentEditor to create tables/blocks on the document. Piece of ode below:
public static RadFixedDocument CreateDocument(){ RadFixedDocument document = new RadFixedDocument(); RadFixedPage page = new RadFixedPage(); page.Size = new Size(600, 750); FixedContentEditor editor = new FixedContentEditor(page); document.Pages.Add(page); editor.Position.Translate(defaultLeftIndent + 330, defaultTopIndent); DrawTable(editor, maxWidth); editor.Position.Translate(defaultLeftIndent, defaultTopIndent + 70); DrawTitle(editor, maxWidth); editor.Position.Translate(defaultLeftIndent, defaultTopIndent + 110); DrawTableWithDetails(editor, maxWidth); editor.Position.Translate(defaultLeftIndent, defaultTopIndent + 220); DrawReceiverTable(editor, maxWidth); private static void DrawTable(FixedContentEditor editor, double maxWidth) { Table table = new Table(); table.LayoutType = TableLayoutType.AutoFit; table.DefaultCellProperties.Padding = new Thickness(1); #region FIRST ROW TableRow firstRow = table.Rows.AddTableRow(); TableCell firstCell = firstRow.Cells.AddTableCell(); Block firstBlock = firstCell.Blocks.AddBlock(); firstBlock.TextProperties.FontSize = 10; firstBlock.TextProperties.Font = FontsRepository.Helvetica; firstBlock.InsertText("xxxxxxxxx"); TableCell secondCell = firstRow.Cells.AddTableCell(); Block secondBlock = secondCell.Blocks.AddBlock(); secondBlock.TextProperties.FontSize = 10; secondBlock.TextProperties.Font = FontsRepository.Helvetica; secondBlock.InsertText(" xxxxxxxxx"); #endregion editor.DrawTable(table, new Size(maxWidth, double.PositiveInfinity)); } private static void DrawTitle(FixedContentEditor editor, double maxWidth) { Block block = new Block(); block.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center; block.TextProperties.Font = FontsRepository.HelveticaBold; block.TextProperties.FontSize = 16; block.InsertText("xxxxxxxxx"); block.InsertText("<xxxxxxxxx>"); editor.DrawBlock(block, new Size(maxWidth, double.PositiveInfinity)); } private static void DrawTableWithDetails(FixedContentEditor editor, double maxWidth) { Table table = new Table(); table.LayoutType = TableLayoutType.FixedWidth; table.DefaultCellProperties.Padding = new Thickness(1); Border border = new Border(); Border whiteBorder = new Border(0, BorderStyle.None, new RgbColor(255, 255, 255)); table.DefaultCellProperties.Borders = new TableCellBorders(border, border, border, border); #region FIRST ROW TableRow firstRow = table.Rows.AddTableRow(); TableCell firstCell = firstRow.Cells.AddTableCell(); Block firstBlock = firstCell.Blocks.AddBlock(); firstBlock.TextProperties.Font = FontsRepository.HelveticaBold; firstBlock.InsertText("xxxxxxxxx"); TableCell secondCell = firstRow.Cells.AddTableCell(); Block secondBlock = secondCell.Blocks.AddBlock(); secondBlock.TextProperties.Font = FontsRepository.HelveticaBold; secondBlock.InsertText("xxxxxxxxx"); #endregion #region SECOND ROW TableRow secondRow = table.Rows.AddTableRow(); firstCell = secondRow.Cells.AddTableCell(); firstCell.Borders = new TableCellBorders(border, border, border, whiteBorder); firstBlock = firstCell.Blocks.AddBlock(); firstBlock.TextProperties.FontSize = 10; firstBlock.InsertText("xxxxxxxxx"); secondCell = secondRow.Cells.AddTableCell(); secondCell.Borders = new TableCellBorders(border, border, border, whiteBorder); secondBlock = secondCell.Blocks.AddBlock(); secondBlock.TextProperties.FontSize = 10; secondBlock.InsertText("xxxxxxxxx"); #endregion editor.DrawTable(table, new Size(maxWidth, double.PositiveInfinity)); } private static void DrawReceiverTable(FixedContentEditor editor, double maxWidth) { Table table = new Table(); table.LayoutType = TableLayoutType.FixedWidth; table.DefaultCellProperties.Padding = new Thickness(1); Border border = new Border(); Border whiteBorder = new Border(0, BorderStyle.None, new RgbColor(255, 255, 255)); table.DefaultCellProperties.Borders = new TableCellBorders(border, border, border, border); #region TABLE CONTENT TableRow firstRow = table.Rows.AddTableRow(); TableCell firstCell = firstRow.Cells.AddTableCell(); Block firstBlock = firstCell.Blocks.AddBlock(); firstBlock.TextProperties.Font = FontsRepository.HelveticaBold; firstBlock.InsertText("xxxxxxxxx"); TableRow secondRow = table.Rows.AddTableRow(); firstCell = secondRow.Cells.AddTableCell(); firstCell.Borders = new TableCellBorders(border, border, border, whiteBorder); firstBlock = firstCell.Blocks.AddBlock(); firstBlock.TextProperties.FontSize = 10; firstBlock.InsertText("xxxxxxxxx"); #endregion editor.DrawBlock(table, new Size(maxWidth, double.PositiveInfinity)); }}