Header not showing up on each page

Hi,

I'm a newbie at using aspose.pdf, so maybe someone can just let me know if there is something wrong with my code.

I'm trying to create a header that willl on top of each page in the pdf I'm generating.

'Create pdf document

Dim pdf1 As Aspose.Pdf.Generator.Pdf = New Aspose.Pdf.Generator.Pdf()

'Instantiate License class and call its SetLicense method to use the license

'Dim license As Aspose.Pdf.License = New Aspose.Pdf.License

'license.SetLicense("Aspose.Pdf.lic")

Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()

'Instantiate First HeaderFooter object and pass the Section reference in which

'the header or footer is to be added

Dim hf1 As Aspose.Pdf.Generator.HeaderFooter = New Aspose.Pdf.Generator.HeaderFooter(sec1)

'Set the header of odd pages of the PDF document

sec1.OddHeader = hf1'Set the header of even pages of the PDF document

sec1.EvenHeader = hf1

'Add Distance From Edge Property to 80 unit Points

hf1.DistanceFromEdge = 80

'Set the First HeaderFooter, top and bottom property respectively

hf1.Margin.Bottom = 50

hf1.Margin.Top = 100

'Instantiate a Text paragraph that will store the content to show as header

Dim t1 As Aspose.Pdf.Generator.Text = New Aspose.Pdf.Generator.Text

Dim head0 As Aspose.Pdf.Generator.Segment = t1.Segments.Add()

t1.TextInfo.FontName =

"Arial"

t1.TextInfo.Color =

New Aspose.Pdf.Generator.Color("Black")

t1.TextInfo.IsTrueTypeFontBold =

True

t1.TextInfo.Alignment = Aspose.Pdf.Generator.

AlignmentType.Center

head0.Content =

"Header Text"

head0.TextInfo.FontSize = 16

hf1.Paragraphs.Add(t1)

No matter how many pages my pdf generates in the body, the header shows up only ONCE on FIRSTt page and then the rest of the page is empty, and regular section paragraphs begin on second page.

Please advise,

S. Abowitz

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.Pdf for .NET.

I checked your scenario with the latest version of Aspose.Pdf for .NET v7.5 and I am unable to reproduce the issue. Please see the following code I used to test the issue and attached is the generated PDF file. Please share your complete code and generated file with us to help us reproduce the issue.

'Create pdf document

Dim pdf1 As Aspose.Pdf.Generator.Pdf = New Aspose.Pdf.Generator.Pdf()

Dim sec1 As Aspose.Pdf.Generator.Section = pdf1.Sections.Add()

'Instantiate First HeaderFooter object and pass the Section reference in which

'the header or footer is to be added

Dim hf1 As Aspose.Pdf.Generator.HeaderFooter = New Aspose.Pdf.Generator.HeaderFooter(sec1)

'Set the header of odd pages of the PDF document

sec1.OddHeader = hf1

'Set the header of even pages of the PDF document

sec1.EvenHeader = hf1

'Add Distance From Edge Property to 80 unit Points

hf1.DistanceFromEdge = 80

'Set the First HeaderFooter, top and bottom property respectively

hf1.Margin.Bottom = 50

hf1.Margin.Top = 100

'Instantiate a Text paragraph that will store the content to show as header

Dim t1 As Aspose.Pdf.Generator.Text = New Aspose.Pdf.Generator.Text

Dim head0 As Aspose.Pdf.Generator.Segment = t1.Segments.Add()

t1.TextInfo.FontName = "Arial"

t1.TextInfo.Color = New Aspose.Pdf.Generator.Color("Black")

t1.TextInfo.IsTrueTypeFontBold = True

t1.TextInfo.Alignment = Aspose.Pdf.Generator.AlignmentType.Center

head0.Content = "Header Text"

head0.TextInfo.FontSize = 16

hf1.Paragraphs.Add(t1)

Dim str As String = ""

Dim i As Int32 = 0

Do While i < 10000

str = str & i

i = i + 1

Loop

sec1.Paragraphs.Add(New Aspose.Pdf.Generator.Text(sec1, str))

pdf1.Save("D:\\AP Data\\November2012\\header.pdf")

Sorry for the inconvenience,

Hi,

Thanks for responding. I compared your code to mine and realized that I was adding each header, footer and body text in as a seperate section. Now that I adjusted my code to all add in same sections, seems to be working ok.

Thanks for your assistance, and letting me know about newer version to download.

-S. Abowitz