Header and Additional Header

hi

i have a header that contain an image and a text and for the same section i have an Additional Header that contain a text and a table. the weird thing is when i generate the pdf document it will display the secion header as the following:

  • the image from the header.
  • the text from the Additional Header.
  • the text from the header.
  • the table from the Additional Header.

is that a normal behavior ????!!!

Thanks for considering Aspose.

Could you provide the codes which can reproduce the same error?

We need to investigate and find out reasons.

this is the code

---------------------------------------------------

Dim ReportHeader As New HeaderFooter(ReportHeaderSection)

ReportHeader.IsFirstPageOnly = True

Dim MyImage As Aspose.Pdf.Image = New Aspose.Pdf.Image(ReportHeader)

MyImage.ImageInfo.File = System.Web.HttpContext.Current.Server.MapPath("Images") & "/iPrintLogo.jpg"

MyImage.ImageInfo.ImageFileType = ImageFileType.Jpeg

MyImage.ImageInfo.Alignment = AlignmentType.Center

MyImage.Margin.Top = 10

ReportHeader.Paragraphs.Add(MyImage)

Dim MyReportTitle As New Text("Employee Details")

MyReportTitle.TextInfo.Alignment = AlignmentType.Center

MyReportTitle.TextInfo.FontSize = "2"

MyReportTitle.Margin.Top = 25

ReportHeader.Paragraphs.Add(MyReportTitle)

ReportHeaderSection.EvenHeader = ReportHeader

ReportHeaderSection.OddHeader = ReportHeader

'****************************

'First Page Header

'------------------------------------------------------

Dim FirstPageHeader As New HeaderFooter(ReportHeaderSection)

Dim EffectiveDate As DateTime = DateTime.Now

Dim FirstPageHeaderText As New Text("Effective Date: " & EffectiveDate.ToString("d/M/yyyy"))

FirstPageHeaderText.TextInfo.Alignment = AlignmentType.Left

FirstPageHeaderText.Margin.Top = 85

FirstPageHeaderText.Margin.Bottom = 5

FirstPageHeaderText.TextInfo.FontSize = "1"

FirstPageHeader.Paragraphs.Add(FirstPageHeaderText)

Dim FirstPageTable As Table = Me.CreateHeaderTable()

FirstPageTable.Margin.Top = 100

FirstPageTable.Margin.Bottom = 15

FirstPageHeader.Paragraphs.Add(FirstPageTable)

FirstPageHeader.IsFirstPageOnly = True

ReportHeaderSection.AdditionalEvenHeader = FirstPageHeader

ReportHeaderSection.AdditionalOddHeader = FirstPageHeader

If you want the first page has a different header with the subsequent pages, you can set the FirstPageHeader.IsFirstPageOnly = True and ReportHeader.IsSubsequentPagesOnly = True.

As for the alignment problem, you can wirte the code like the following:

Dim text2 As Text = New Text("page $p of $P")
text2.TextInfo.Alignment = AlignmentType.Right

Dim CCell2 As Aspose.Pdf.Cell = row1.Cells.Add()
CCell2.Paragraphs.Add(text2)

I have attached the modified code.