How to align the header/footer to left or center or right?

Hi, support,

I used Words.dll based on VB.net to add new header/footer, but failed to set its alignment property.
My codes is as follow:

document = New Global.Aspose.Words.Document(sFile)
For Each section As Global.Aspose.Words.Section In document.Sections
For Each Header As Global.Aspose.Words.HeaderFooter In section.HeadersFooters
If Header.HeaderFooterType = Global.Aspose.Words.HeaderFooterType.HeaderPrimary Or _
Header.HeaderFooterType = Global.Aspose.Words.HeaderFooterType.HeaderFirst Or _
Header.HeaderFooterType = Global.Aspose.Words.HeaderFooterType.HeaderEven Then
Header.Remove()
End If
Next
Next
num = &H21
font = builder.Font
builder.Font.Scaling = num
builder.Font.Spacing = -1
builder.Font.Size = 9
builder.Bold = 0
builder.Italic = 0
builder.Underline = 0
builder.Font.StrikeThrough = 0
builder.ParagraphFormat.Borders.Bottom.LineStyle = Global.Aspose.Words.LineStyle.Single
builder.Font.Color = LColor.BackColor
builder.Font.Name = CmbFontname.Text
builder.ParagraphFormat.Alignment = Global.Aspose.Words.ParagraphAlignment.Center
’ set the alignment of added header to center, but the alignment of the added header in the output file is still left not center. In some case, there is one more redundant hard return added to the header.
builder.Write(headContent) ’ add new header content to the header section


How to make the builder.ParagraphFormat.Alignment = Global.Aspose.Words.ParagraphAlignment.Center valid and avoid one more redundant hard return for the added header.

Thanks for your help!

Ducaisoft

@ducaisoft,

To ensure a timely and accurate response, please ZIP and attach the following resources here for testing:

  • Your simplified input Word document
  • Aspose.Words 19.5 generated output document showing the undesired behavior
  • Your expected document showing the correct output. You can create expected document by using MS Word.
  • Please also create a simplified standalone console application (source code without compilation errors) that helps us to reproduce your current problem on our end and attach it here for testing. Please do not include Aspose.Words DLL files in it to reduce the file size.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.