I am having a problem trying to assign a text value to a Rich text control. I´m using Aspose.Words.dll version 15.3.0.
This is my code:
wordLicense = new License();
wordLicense.SetLicense(licensePath);
Document doc = new Document(templatePath);
foreach (StructuredDocumentTag sdt in doc.GetChildNodes(NodeType.StructuredDocumentTag, true))
{
if (sdt.SdtType == SdtType.RichText)
{
if (sdt.Tag.Equals(field))
{
sdt.RemoveAllChildren();
Paragraph para = new Paragraph(doc);
Run r1 = new Run(doc);
r1.Text = value;
para.AppendChild(r1);
sdt.AppendChild(para);
}
}
}
doc.Save(templatePath.Replace(".docx", ".pdf"));
doc = null;
wordLicense = null;
I receive an exception at sdt.AppendChild that reports:
System.ArgumentException: Cannot insert a node of this type at this location.
I attach the Word file.
Thank you.