Trouble with header containing table



I am creating a report that will have multiple sections in it. Each section will have a different header. Part of the header is the same throughout the pdf so I created a table and use that in the header.

I'm not sure what I am doing wrong but the text in the table looks like it is being written twice. Here is some code that can recreate the problem. Thanks for your help.

string [] strHeadings = new string [] {"one", "two_two", "three\nfour", "five", "six\nseven", "eight", "nine", "10", "11", "12\n13"};
//create table to be used in header
Table headerTable = new Table();
headerTable.DefaultCellBorder = new BorderInfo((int)BorderSide.Bottom | (int)BorderSide.Top ,1.0F);
//text info
headerTable.DefaultCellTextInfo = tiBold;
headerTable.ColumnWidths = "50 50 50 50 50 50 50 50 50 50";
//fill heading cells
Row rowItem = new Row(headerTable);
rowItem.DefaultCellTextInfo = tiBold;
for (int i = 0; i < 10; i++)
//only use non empty columns
Cell cell = new Cell(rowItem);
cell.DefaultCellTextInfo.Alignment = AlignmentType.Center;
cell.VerticalAlignment = VerticalAlignmentType.Bottom;
cell.DefaultCellTextInfo = tiBold;
Text cellText = new Text(strHeadingsIdea.Replace('_',' '));
//Attach to Table

//create another section
Section section2 = this._pdfDoc.Sections.Add();
section2.PageInfo.Margin.Top = 30;
section2.PageInfo.Margin.Bottom = 30;
section2.PageInfo.Margin.Left = 30;
section2.PageInfo.Margin.Right = 30;
section2.PageInfo.PageHeight = PageSize.LetterHeight;
section2.PageInfo.PageWidth = PageSize.LetterWidth;
section2.IsLandscape = true;

HeaderFooter headerTitle = new HeaderFooter(section2);
section2.OddHeader = section2.EvenHeader = headerTitle;
headerTitle.Margin.Top = 15;
headerTitle.Margin.Bottom = 10;

//Create the Title text
Text textTitle = new Text("This is the Title\nTwo Lines");
textTitle.TextInfo = tiBold;
textTitle.TextInfo.Alignment = AlignmentType.Center;
//Add Header table

//new table
Table tableBody2 = new Table(section2);
tableBody2.ColumnWidths = "100 100 100 100 100";
tableBody2.DefaultCellBorder = new BorderInfo((int)BorderSide.All,1.0F);
tableBody2.DefaultCellTextInfo = tiCenter;
tableBody2.DefaultCellPadding.Bottom = tableBody2.DefaultCellPadding.Left
= tableBody2.DefaultCellPadding.Right = tableBody2.DefaultCellPadding.Top = 2;
Row rowItem2 = new Row(tableBody2);

rowItem2.Cells.Add("One").VerticalAlignment = VerticalAlignmentType.Bottom;
rowItem2.Cells.Add("Five").VerticalAlignment = VerticalAlignmentType.Center;




Thank you for considering Aspose.

I have fixed this bug. Please download hotfix here.


Thanks for your quick response!

This fix works for the first page of my report. However, if there are more pages, the header with the table is still exhibiting strage behavior.

Add this code to the example I sent to recreate the new problem.

for (int i = 0; i < 100; i++)
Text text1 = new Text(String.Format("Row: {0}",i.ToString()));


I'm having another problem I'm struggling with regarding a section header containing a table. Sometimes part of the section header (the table) is displaying after the text on the diplay. Have you ever seen this happen before?

I use the same code to generate multiple reports. The table size and contents are dynamically built for each report so I can't give you a specific piece of code to re-create the problem. I'm hoping you might point me in the right direction as to why a header would beteween other section content. Thanks.


I have fixed the first problem. Please download hotfix again and test the second problem with the hotfix. If the error still be there, please let me know and you’d better provide a example pdf document with the error if you can’t provide code to reproduce the error.


The hotfix solved the first problem and part of the second problem. However, I am still having trouble with my main table. I have emailed you an attachment of pdf file created. The pdf contains one section - the section contains a header with text and a table and the body of the pdf is made up of one table. You’ll see that the body on page 2 and 3 are not formatting correctly. Thanks.