PDFsharp & MigraDoc Foundation http://forum.pdfsharp.com/ |
|
table will not break over multiple pages http://forum.pdfsharp.com/viewtopic.php?f=2&t=781 |
Page 1 of 1 |
Author: | mikesowerbutts [ Wed Jul 08, 2009 4:00 pm ] |
Post subject: | table will not break over multiple pages |
Hi, I am creating a table with a lot of rows, for some reason, the table will not break over multiple pages, each row is quite small - there are just a lot of them! instead of breaking onto multiple pages, the rows which wont fit on the starting page are just cut off. I have tried setting KeepTogether to false but it doesnt seem to make any difference! here is the function which creates the table: Code: public MigraDoc.DocumentObjectModel.Tables.Table buildSizedTable(int rows, List<int> colWidths, List<TableElement> cellData, MigraDoc.DocumentObjectModel.Font font) { int _cellDataIdx = 0; MigraDoc.DocumentObjectModel.Tables.Table _table = new Table(); _table.TopPadding = 3; _table.BottomPadding = 3; _table.LeftPadding = 3; _table.RightPadding = 3; //_table.KeepTogether = false; MigraDoc.DocumentObjectModel.Font _font = font.Clone(); for (int cols = 0; cols < colWidths.Count; cols++) { _table.AddColumn(((page.Width - leftMargin - rightMargin) / 100) * colWidths[cols]); } try { for (int r = 0; r < rows; r++) { Row _row = _table.AddRow(); _row.HeightRule = RowHeightRule.Auto; for (int c = 0; c < colWidths.Count; c++) { Cell _cell = _row.Cells[c]; if (cellData[_cellDataIdx].format.borders.IndexOf("T") != -1) { _cell.Borders.Top.Width = cellData[_cellDataIdx].format.borderWidth; } if (cellData[_cellDataIdx].format.borders.IndexOf("B") != -1) { _cell.Borders.Bottom.Width = cellData[_cellDataIdx].format.borderWidth; } if (cellData[_cellDataIdx].format.borders.IndexOf("L") != -1) { _cell.Borders.Left.Width = cellData[_cellDataIdx].format.borderWidth; } if (cellData[_cellDataIdx].format.borders.IndexOf("R") != -1) { _cell.Borders.Right.Width = cellData[_cellDataIdx].format.borderWidth; } font.Bold = cellData[_cellDataIdx].format.bold; font.Italic = cellData[_cellDataIdx].format.italic; font.Size = cellData[_cellDataIdx].format.size; font.Underline = cellData[_cellDataIdx].format.underlined; if (cellData[_cellDataIdx].fill) { _cell.Shading.Color = cellData[_cellDataIdx].fillColor; } if (cellData[_cellDataIdx].mergeRight > 0) { _cell.MergeRight = cellData[_cellDataIdx].mergeRight; } if (cellData[_cellDataIdx].mergeDown > 0) { _cell.MergeDown = cellData[_cellDataIdx].mergeDown; } buildCell(_cell, cellData[_cellDataIdx], font); _cellDataIdx++; } } _table.KeepTogether = false; document.LastSection.Add(_table); } catch { } return _table; } The cellData object in the parameters is basically an array of objects holding styling information for each cell. Im really stuck on this - I am creating quite a lot of print documents, all of which have an unfixed number of rows in each table, so this is a big problem for me! Any ideas? |
Author: | mikesowerbutts [ Fri Jul 10, 2009 9:25 am ] |
Post subject: | Re: table will not break over multiple pages |
ok this was to do with how i was rendering/adding pages rather than the tables not splitting properly - fixed now! |
Author: | ragu [ Tue Sep 01, 2009 8:44 pm ] |
Post subject: | Re: table will not break over multiple pages |
Hi.. i am stuck with the problem as yours - hundreds of rows coming from a database and not being able to break table over multiple pages. Could you please tell me how you fixed this problem by rendering/adding pages to accommodate huge tables across pages. Any input/code would help. Thanks.. Ragu |
Author: | ragu [ Wed Sep 09, 2009 1:49 pm ] |
Post subject: | Re: table will not break over multiple pages |
Well, i managed to solve this. For those who might face similar issues, here's what helped me: - used MigraDoc entirely, the Section and Renderer objects - created table using Tables.Table and adding rows to it (as they come from db) - adding the table to section > Section.Add(table) - finally adding the section to the PDF document, using the Renderer Now the table stretches across multiple pages.. Thanks indeed to PDFsharp and MigraDoc |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |