Find and Replace Text within a TextBox

Hi,


I have a word document (Attached) which i am trying to do a find and replace of text box values from my specific “Tokens” e.g. {{FirstName}} and replace with “Chris” for example.

Below is an example of the code i am using. Text within the body content is getting replaced no problem however the text within the TextBoxes is not being replace. How can i get the value of items within the text box to replace the content?

public static byte[] ConvertFromWord(byte[] wordDocument)
{
using(MemoryStream input = new MemoryStream(wordDocument))
{
Document doc = new Document(input);

doc.Range.Replace(@"{{FirstName}}", “Chris”, false, true);
doc.Range.Replace(@"[[FirstName]]", “John”, false, true);
doc.Range.Replace(“FirstName”, “James”, false, true);

// Create a new memory stream.
using (MemoryStream output = new MemoryStream())
{
// Save the document to stream.
doc.Save(output, SaveFormat.Pdf);

return output.ToArray();
}
}
}

Can anyone help with this?

Hi Chris,


Thanks for contacting support and sorry for the delayed response.

As your query is related to Aspose.Words, so I am moving it to respective forum and my fellow workers taking care of Aspose.Words will further look into this matter and will reply accordingly. We are sorry for this delay and inconvenience.

Hi Chris,


Thanks for your inquiry. Your
input document is empty. Could you please attach your input Word
document again here for testing? I will investigate the issue on my side
and provide you more information.