We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Find Text in Word Document Header Footer & Replace it with new Text Image Content using C# .NET

@tahir.manzoor

Hi,

I am trying to replace the header text it is replacing but the text after space cannot be shown in header.

I have attached input,output,sample template and my coding.
Kindly do the needful.
Header Replacement.zip (110.4 KB)

@Ramyamai,

After an initial test with the licensed latest version of Aspose.Words for .NET i.e. 20.2, we were unable to reproduce this issue on our end. Please see the output DOCX document which was generated on our end by using the following simple C# code:

C# Code:

Document doc = new Document(@"E:\\Temp\\Header Replacement\\Sample_Template.docx");

DocumentBuilder builder = new DocumentBuilder(doc);
BookmarkCollection bb = doc.Range.Bookmarks;

FindReplaceOptions options = new FindReplaceOptions();
doc.Sections[0].Range.Replace("@Name", "Enable User", options);

doc.Save("E:\\Temp\\Header Replacement\\20.2.docx");

Hope, this helps.