Hello Dirk,
Thanks for your sharing via email.
I checked our records and found that you previously reported a similar issue (SPIREDOC-6124). My colleague Andy has provided you the following solution. However, I notice that your code does not use this solution, so I suggest you try this code to see if the issue occurs.
- Code: Select all
private static Document SetInhalt(Document doc)
{
const string Pattern = @"\{+(\s?)+(.*?)+(\s?)+\}";
const string Patter = @"""[^""]*""";
var docVarPattern = new Regex(Pattern);
var docVarNamePattern = new Regex(Patter);
var selections = doc.FindAllPattern(docVarPattern);
foreach (var selection in selections)
{
var name = ExtractName(docVarNamePattern.Match(selection.SelectedText).Value);
var range = selection.GetAsOneRange();
var index = range.OwnerParagraph.ChildObjects.IndexOf(range);
Field field = new Field(doc);
field.Type = FieldType.FieldAdvance;
field.Code = " DOCVARIABLE " + name + " ";
range.OwnerParagraph.ChildObjects.Insert(index++, field);
FieldMark fm = new FieldMark(doc, FieldMarkType.FieldSeparator);
range.OwnerParagraph.ChildObjects.Insert(index++, fm);
FieldMark endFM = new FieldMark(doc, FieldMarkType.FieldEnd);
field.End = endFM;
range.OwnerParagraph.ChildObjects.Insert(index++, endFM);
range.OwnerParagraph.ChildObjects.Remove(range);
}
return doc;
}
If the issue persists after trying, we cannot directly run your code due to many custom methods in your code, please provide your runnable project to help us investigate further.
Sincerely,
Brian
E-iceblue support team