Error in updatePageLayout

Hi Team,

I am running into an error when executing doc.UpdatePageLayout() or doc.Save() methods.

I am following the below steps

  1. Open existing document using OpenXML
  2. Read all hyperlinks in the document
  3. Identify the document url from the hyperlink, download the corresponding excel and extract the data as a table from excel using OpenXML.
  4. Insert the extracted table in place of the hyperlink using openxml
  5. save the document using openXML
  6. Open the same document using aspose.words
  7. Create a table and insert the above content including the table inserted a few steps ago
  8. Insert the table on the document using aspose
  9. save the document or call UpdatePageLayout

Once the above steps are followed, I am not able to save the document or convert into pdf.

Can you help with this?

Below is the error details

doc.UpdatePageLayout()
   at    .(Table , Int32 )
   at    .(Table )
   at    .(Table )
   at Aspose.Words.CompositeNode.AcceptCore(DocumentVisitor visitor)
   at Aspose.Words.CompositeNode.AcceptChildren(DocumentVisitor visitor)
   at Aspose.Words.CompositeNode.AcceptCore(DocumentVisitor visitor)
   at Aspose.Words.CompositeNode.AcceptChildren(DocumentVisitor visitor)
   at Aspose.Words.CompositeNode.AcceptCore(DocumentVisitor visitor)
   at Aspose.Words.CompositeNode.AcceptChildren(DocumentVisitor visitor)
   at Aspose.Words.CompositeNode.AcceptCore(DocumentVisitor visitor)
   at Aspose.Words.CompositeNode.AcceptChildren(DocumentVisitor visitor)
   at Aspose.Words.CompositeNode.AcceptCore(DocumentVisitor visitor)
   at Aspose.Words.CompositeNode.AcceptChildren(DocumentVisitor visitor)
   at Aspose.Words.CompositeNode.AcceptCore(DocumentVisitor visitor)
   at Aspose.Words.CompositeNode.AcceptChildren(DocumentVisitor visitor)
   at Aspose.Words.CompositeNode.AcceptCore(DocumentVisitor visitor)
   at    .( ​  )
   at Aspose.Words.Document.(Stream , String , SaveOptions )

Below is the method I am using to insert

void InsertTable(Table table, Node target) 
{
	var parent = target.ParentNode;

	documentBuilder.MoveTo(target.StartNode);

	Paragraph breakPara3 = CreateBreakParagraph();
	parent.InsertAfter(breakPara3, target.StartNode);

	//insert table in the document
	var updatedTable = parent.InsertAfter(table.Clone(true), breakPara3);

	parent.InsertAfter(CreateSpaceParagraph(), updatedTable);
	parent.InsertBefore(CreateSpaceParagraph(), updatedTable);

	try { documentBuilder.MoveTo(updatedTable.NextSibling); } catch { }

	documentBuilder.InsertBreak(BreakType.ParagraphBreak);
	documentBuilder.InsertBreak(BreakType.LineBreak);
	documentBuilder.InsertBreak(BreakType.LineBreak);

	doc.UpdatePageLayout();
}

@arunsandeep Could you please provide your input document and full code that will allow us to reproduce the problem? Or better if possible, create a simple console application that will demonstrate the problem. We will check the issue and provide you more information.