TableOverflow with different header and footer

TableOverflow with different header and footer

Forum member · May 22, 2008
I have the following document setup First Page HeaderType1(only on first page) Table data starts, could be 100 pages long FooterType1 SecondPage to Second Last page HeaderType2 (on all pages except first page) continuation of table data rows FooterType1 LastPage HeaderType2(on all pages except first page) continuation of table data rows Final Summary information added that could span several pages(should this be a new table or add into the existing tables rows?) FooterType1 I am very confused how to set this up. Right now i hard code how many rows per page for the table data but i don't like that. It also messes up when the last page arrives and i don't know how long the Final Summary information would be. If you could give me a clear example of how to set this up it would be greatly appreciated. Cheers

Re: TableOverflow with different header and footer

Support · May 23, 2008
Hello, Yes, you can create a PDF as you described above without any problem using our Generator product. Can you please send a mail to our [^a|mailto:support@cete.com|Support Team^] so that they can send you some sample example for this. Thanks, ceTe Software Support Team.

Re: TableOverflow with different header and footer

Forum member · Nov 8, 2018
Can you send me an example of code for the issue mentioned in the previous post?

Re: TableOverflow with different header and footer

Support · Nov 8, 2018
Hello, Here is the code sample you requested. float x = 0; float y = 0; float span = 20; float headerGap = 30; Document document = new Document(); Page page = new Page(); Label footer = new Label("Footer Type 1", x, page.Dimensions.Body.Height - span, 200, 20); Template footerTemplate = new Template(); footerTemplate.Elements.Add(footer); document.Template = footerTemplate; Label header = new Label("Header Type 1", x, y, 200, 20); y += headerGap; page.Elements.Add(header); Table2 table = new Table2(x, y, 200, 200); table.Columns.Add(100); table.Columns.Add(100); for (int i = 0; i < 100; i++) { Row2 row = table.Rows.Add(); row.Cells.Add("Row " + (i + 1) + "; Cell 1"); row.Cells.Add("Row " + (i + 1) + "; Cell 2"); } if (page.Dimensions.Body.Height - 60 < table.GetRequiredHeight()) table.Height = page.Dimensions.Body.Height - 60; else table.Height = table.GetRequiredHeight(); page.Elements.Add(table); table = table.GetOverflowRows(); document.Pages.Add(page); y = 0; Label header1 = new Label("Header Type 2", x, y, 200, 20); y += headerGap; Template header1Template = new Template(); header1Template.Elements.Add(header1); Section section1 = document.Sections.Begin(); section1.Template = header1Template; float lastY = 0; do { page = new Page(); if (page.Dimensions.Body.Height - 60 < table.GetRequiredHeight()) table.Height = page.Dimensions.Body.Height - 60; else table.Height = table.GetRequiredHeight(); page.Elements.Add(table); document.Pages.Add(page); lastY = table.Height + headerGap + span; table = table.GetOverflowRows(); } while (table != null); Table2 summary = new Table2(x, lastY, 400, 200); summary.Columns.Add(200); summary.Columns.Add(200); for (int i = 0; i < 2; i++) { Row2 row = summary.Rows.Add(); row.Cells.Add("Summary Row " + (i + 1) + "; Summary Cell 1"); row.Cells.Add("Summary Row " + (i + 1) + "; Summary Cell 2"); } page.Elements.Add(summary); document.Draw("output.pdf");