Hi
We have Aspose.Words 14.2, and FieldsHelper is used to replace IFs with static texts, which worked fine. However, in a recent case, the code threw an exception from the following highlighted line.
My questions are,
- We know that FieldsHelper is not part of Aspose.Words. But is there an available fix in the helper class? The code should handle the case when the nextParagraph is null.
- If not, is there an equivalent built-in feature in the latest Aspose.Words, which is more robust?
Please advise!
function call:
FieldsHelper.ConvertFieldsToStaticText(doc, FieldType.FieldIf);
Exception thrown from below:
public override VisitorAction VisitParagraphEnd(Paragraph paragraph)
{
if (mFieldDepth > 0)
{
// The field code that is being converted continues onto another paragraph. We
// need to copy the remaining content from this paragraph onto the next paragraph.
Node nextParagraph = paragraph.NextSibling;
// Skip ahead to the next available paragraph.
while (nextParagraph != null && nextParagraph.NodeType != NodeType.Paragraph)
nextParagraph = nextParagraph.NextSibling;
// Copy all of the nodes over. Keep a list of these nodes so we know not to remove them.
while (paragraph.HasChildNodes)
{
mNodesToSkip.Add(paragraph.LastChild);
((Paragraph)nextParagraph).PrependChild(paragraph.LastChild); //<== nextParagraph is somehow Null!!**
}
paragraph.Remove();
}
return VisitorAction.Continue;
}
Regards,
Jason