Hi,
My problem is, I generate a word document from a dot file, and replace several dynamic fields(DOCPROPERY). Then I save the document. The reult is that all dynaic field fields are chanhed and not dynamic anymore.
Some days after the generation I need to put a signature, date of the letter on the document, wherefor I also use dynamic fields (for the original dot file)
How can I update fields, but keep some fields untouched (the fields with DOCPROPERTY DatumDocument, TekenenFuleName and Tekenen (is a link to a bitmap) needed to be untouched)
Most of the fields are in the same textfield of the Range.
My code is:
Aspose.Words.Document doc = new Aspose.Words.Document(template);
foreach(DocumentProperty prop in doc.CustomDocumentProperties)
{
string wordPropertyName = prop.Name;
string fileNetPropertyName;
WordPropertyMapping mapping = FindMapping(mappings, wordPropertyName);
if (mapping.FileNetPropertyName != null)
{
fileNetPropertyName = mapping.FileNetPropertyName;
}
else
{
fileNetPropertyName = wordPropertyName;
}
if (props.ContainsKey(fileNetPropertyName) && (props[fileNetPropertyName] != null))
{
if (doc.CustomDocumentProperties.Contains(fileNetPropertyName))
doc.CustomDocumentProperties[fileNetPropertyName].Value = props[fileNetPropertyName].ToString();
// else
// doc.CustomDocumentProperties.Add(fileNetPropertyName, props[fileNetPropertyName].ToString());
// Word.DocumentPropertyHelper.SetPropertyValue(doc.CustomDocumentProperties, wordPropertyName, props[fileNetPropertyName].ToString());
}
else if (mapping.Default != null)
{
if (doc.CustomDocumentProperties.Contains(fileNetPropertyName))
doc.CustomDocumentProperties[fileNetPropertyName].Value = mapping.Default.ToString();
// else
// doc.CustomDocumentProperties.Add(fileNetPropertyName, mapping.Default.ToString());
// Word.DocumentPropertyHelper.SetPropertyValue(doc.CustomDocumentProperties, wordPropertyName, mapping.Default.ToString());
}
if (!fileNetPropertyName.Contains(ConfigurationManager.AppSettings["SignatureDocumentProperty"]))
doc.Range.UpdateFields();
// if (unlink )
}
// doc.UpdateFields();
Thanks
Ernst