Replace Header in the word document

Hi Team,

We are using Aspose .NET for word.

There is a template file from which we create the actual output file.
The template file will have the header text in the following manner :

Our Ref:

We need to replace the part of the header with another value.

We are thinking in the below lines.

        foreach(Section section in doc.Sections)
        {
            foreach(HeaderFooter hf in section.HeadersFooters)
            {
                if(hf.GetText().ToUpper().Contains("<HEADER BORROWER NAME>"))
                {
                    string header = hf.GetText().ToUpper().Replace("<HEADER BORROWER NAME>", "Borrower Name 1");
                    ….
                }
            }
        }

We are not able to assign header value to this. Let us know on how to proceed with this

@balaji7,

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.9 generated output document showing the undesired behavior
  • Your expected document showing the correct output. You can create expected document by using MS Word 2019.
  • Please also create a standalone simple 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.