Adjusting TextState of table cell in header/footer

I have a use case where I need to build a fairly complicated table in the header and footer of a document. It appears that the TextState is not being applied when the table is rendered. Here is the simplest example I could come up with to demonstrate this:



Document pdf = new Document();
Page page = pdf.Pages.Add();

TextSegment segment = new TextSegment(“This is some large blue text!”);
segment.TextState.Font = FontRepository.FindFont(“Times New Roman”);
segment.TextState.FontSize = 20;
segment.TextState.ForegroundColor = Color.Blue;
segment.TextState.FontStyle = FontStyles.Bold;

TextFragment fragment = new TextFragment();
fragment.Segments.Add(segment);

Table table = new Table();
table.ColumnWidths = “400”;
Row row = table.Rows.Add();
Cell cell = row.Cells.Add();
cell.Paragraphs.Add(fragment);

HeaderFooter header = new HeaderFooter();
page.Header = header;

// text is formatted correctly when added to page body
page.Paragraphs.Add(table);

// the exact same text is not formatted when added to header or footer
header.Paragraphs.Add(table);

pdf.Save(@“c:\headtable.pdf”);


Please let me know if there is something I should do differently or if this is a bug.

Hi Keith,

Thanks for your inquiry. I have tested your scenario with Aspose.Pdf for .NET 10.5.0 and managed to observe the reported issue of TextState in HeaderFoorter object. For further investigation, I have logged an issue in our issue tracking system as PDFNEWNET-38892 and also linked your request to it. We will keep you updated via this thread regarding the issue status.

Please feel free to contact us for any further assistance.

<span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif”;mso-fareast-font-family:
Calibri;color:#333333;mso-ansi-language:EN-US;mso-fareast-language:EN-US;
mso-bidi-language:AR-SA”>Best Regards

The issues you have found earlier (filed as PDFNET-38892) have been fixed in Aspose.PDF for .NET 18.11.