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();
}
}
}