Hello,
I am creating a header object like so:
Aspose.Pdf.Text.TextState tsNormal = new Aspose.Pdf.Text.TextState() { FontSize = 8F, HorizontalAlignment = HorizontalAlignment.Right };
Aspose.Pdf.Table headerTable = new Aspose.Pdf.Table();
headerTable.ColumnWidths = string.Format("{0} {1}", 228, 228);
Aspose.Pdf.Row headRowOne = headerTable.Rows.Add();
Aspose.Pdf.Row headRowTwo = headerTable.Rows.Add();
headRowOne.Cells.Add("", tsNormal);
headRowOne.Cells.Add("", tsNormal);
headRowTwo.Cells.Add(string.Format("Engagement Name: {0}\r\nLodgement ID: {1}", EngagementName, lodgeId), tsNormal);
headRowTwo.Cells.Add(string.Format("Generated on {0}\r\nGenerated by {1}", DateTime.Now.ToShortDateString(), Context.User.Identity.Name), tsNormal);
Aspose.Pdf.HeaderFooter headerPortrait = new Aspose.Pdf.HeaderFooter();
headerPortrait.Paragraphs.Add(headerTable);
I create a footer in a similar way but with the “$p” token to refer to the page number
I create pages in a separate routine where I pass in the header and footer objects. These pages have tables which sometimes split across a few pages.
protected Aspose.Pdf.Page GenerateSectionStatementInfo(Aspose.Pdf.Document doc, Aspose.Pdf.HeaderFooter header, Aspose.Pdf.HeaderFooter footer)
{
Aspose.Pdf.Page pg = doc.Pages.Add();
pg.Header = header;
pg.Footer = footer;
...
return pg;
}
The document is created successfully but the header and footer appears about 10 points lower on each page, after a few pages the footer disappears off the bottom of the page and the header is over the top of the page content.
Also, on each new Page object the page number goes back to “2” but then on the next page the correct number is reported until the first page of a new Page object starts. So across all my footers I get [2,3,4,5,6,7][2,9,10][2,12,13][2,15,16][2,18] (where […] represents one Page object).
Any help would be much appreciated.
Many thanks,