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