We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Table of Contents + UpdateFields method

After installing apsose.words 9.0, I modified the the code displayed in the following post : http://www.aspose.com/documentation/.net-components/aspose.words-for-.net-and-java/aspose.words.documentbuilder.inserttableofcontents.html to update the fields prior to saving the document as follows:



and received the following error:

{"Exception of type 'System.OutOfMemoryException' was thrown."}

[System.OutOfMemoryException]: {"Exception of type 'System.OutOfMemoryException' was thrown."}

Data: {System.Collections.ListDictionaryInternal}

HelpLink: null

InnerException: null

Message: "Exception of type 'System.OutOfMemoryException' was thrown."

Source: "Aspose.Words"

StackTrace: " at ..()\r\n at ..Clone()\r\n at Aspose.Words.Inline.Clone(Boolean isCloneChildren)\r\n at ..( )\r\n at ..()\r\n at ..()\r\n at ..OnChildNode()\r\n at ..()\r\n at ..( , Node , )\r\n at ..()\r\n at Aspose.Words.Fields.Field.( )\r\n at Aspose.Words.Fields.Field.Update()\r\n at Aspose.Words.Range.UpdateFields()\r\n at Aspose.Words.Document.UpdateFields()\r\n at SandBox_WindowsApp.AsposeTesting.TableOfContents.BuildAsposeTOC() in C:\\DEV\\SandBox\\WindowsApp_SandBox\\AsposeTesting\\TableOfContents.cs:line 72"

TargetSite: {. ()}

when that didn't work, i also tried saving the doc and re-opening, updating and saving again... with the same result. Any ideas?

Thanks, mlb


<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for reporting this problem to us. Most likely, the problem occurs because you inserted TOC into the paragraph with heading style. You can easily resolve the problem by adding one additional line to your code. See the following snippet of code:

' Insrt a table of contents at the beginning of the document.

builder.InsertTableOfContents("\o ""1-3"" \h \z \u")


' Build a document with complex structure by applying different heading styles thus creating TOC entries.

builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1

builder.Writeln("Heading 1")

Your request has been linked to the appropriate issue. You will be notified as soon as the original problem is resolved.

Best regards.

The issues you have found earlier (filed as 15752) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.