Here is my style:
Dim sectionHeaderStyle As TextInfo = New TextInfo()
sectionHeaderStyle.FontName = "Arial"
sectionHeaderStyle.FontSize = 16
sectionHeaderStyle.Alignment = AlignmentType.Left
sectionHeaderStyle.IsTrueTypeFontBold = True
sectionHeaderStyle.IsTrueTypeFontItalic = False
sectionHeaderStyle.Color = New Aspose.Pdf.Color("Black")
' TODO: why are we getting a double border?
sectionHeaderStyle.TextBorder = New BorderInfo(15) ' 15 is binary 1111 so it means all four borders
sectionHeaderStyle.BackgroundColor = New Aspose.Pdf.Color("Silver")
sectionHeaderStyle.IsUnderline = False
And here is where I create a Text
object using that style:
<Extension>
Public Function CreateBlankSection(ByVal pdf As Pdf, ByVal marginInfo As MarginInfo, ByVal sectionHeaderStyle As TextInfo, ByVal mainStyle As TextInfo, ByVal headerText As String) As Section
' Add a blank section into the PDF document
Dim sec As Section = pdf.Sections.Add()
sec.PageInfo.PageWidth = 8.5 * 72
sec.PageInfo.PageHeight = 11 * 72
sec.PageInfo.Margin = marginInfo
sec.TextInfo = mainStyle
' Add the section title
Dim text As Text = sec.CreateText(sectionHeaderStyle, headerText)
' Return the section created
Return sec
End Function
<Extension>
Public Function CreateText(ByVal sec As Section, ByVal style As TextInfo, ByVal text As String) As Text
Dim txt As Text = New Text(sec, text)
txt.TextInfo = style
sec.Paragraphs.Add(txt)
Return txt
End Function
But when I render the section (in this screenshot I added some more tables and text besides the header), I get two borders?!
What's going on here? How can I get rid of the inner border? All I want is the outer border.
As suggested in the comment under your question, check the following sample code snippet which is DOM Based (Aspose.Pdf), and creates a table in the PDF document.
Below is the sample output generated by the above code snippet. You can notice that the text content is properly aligned along with its borders.