Hi Team,
I am running into an error when executing doc.UpdatePageLayout() or doc.Save() methods.
I am following the below steps
- Open existing document using OpenXML
- Read all hyperlinks in the document
- Identify the document url from the hyperlink, download the corresponding excel and extract the data as a table from excel using OpenXML.
- Insert the extracted table in place of the hyperlink using openxml
- save the document using openXML
- Open the same document using aspose.words
- Create a table and insert the above content including the table inserted a few steps ago
- Insert the table on the document using aspose
- 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();
}