We have a process where a user can upload a document, we then present in an browser based rich text editor so that they may modify the uploaded document. We then save the html into a word document, and then re-open the word document so that we can convert it to plain text. However, it appears that for one reason or another in some instances the word document created from the saved html causes aspose.words to throw the following exception:
Exception Message: Length cannot be less than zero.
Parameter name: length
--------------------------------------------------------------------------------
Exception Stacktrace
--------------------------------------------------------------------------------
at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
at x722d80085b19d13f.x01f345749770e63a.x53d39342dc45172d(String xb41faee6912a2313)
at x722d80085b19d13f.x01f345749770e63a.xe4fd28685b34ecc7(String xb41faee6912a2313)
at x722d80085b19d13f.xc045be5d79e471b9.xe4fd28685b34ecc7(String xb41faee6912a2313)
at x722d80085b19d13f.xc045be5d79e471b9.VisitRun(Run run)
at Aspose.Words.Run.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.x464d2134480a7bf2(DocumentVisitor x672ff13faf031f3d)
at Aspose.Words.CompositeNode.xf7ae36cd24e0b11c(DocumentVisitor x672ff13faf031f3d)
at Aspose.Words.Paragraph.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.x464d2134480a7bf2(DocumentVisitor x672ff13faf031f3d)
at Aspose.Words.CompositeNode.xf7ae36cd24e0b11c(DocumentVisitor x672ff13faf031f3d)
at Aspose.Words.Tables.Cell.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.x464d2134480a7bf2(DocumentVisitor x672ff13faf031f3d)
at Aspose.Words.CompositeNode.xf7ae36cd24e0b11c(DocumentVisitor x672ff13faf031f3d)
at Aspose.Words.Tables.Row.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.x464d2134480a7bf2(DocumentVisitor x672ff13faf031f3d)
at Aspose.Words.CompositeNode.xf7ae36cd24e0b11c(DocumentVisitor x672ff13faf031f3d)
at Aspose.Words.Tables.Table.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.x464d2134480a7bf2(DocumentVisitor x672ff13faf031f3d)
at Aspose.Words.CompositeNode.xf7ae36cd24e0b11c(DocumentVisitor x672ff13faf031f3d)
at Aspose.Words.Body.Accept(DocumentVisitor visitor)
at x722d80085b19d13f.xc045be5d79e471b9.x51ee56decc29a9da(Section xb32f8dd719a105db)
at x722d80085b19d13f.xc045be5d79e471b9.x8cac5adfe79bc025(x8556eed81191af11 x5ac1382edb7bf2c2)
at Aspose.Words.Document.xf381a641001e6830(Stream xcf18e5243f8d5fd3, String xafe2f3653ee64ebc, SaveOptions xc27f01f21f67608c)
at Aspose.Words.Document.Save(String fileName, SaveOptions saveOptions)
at HRNet.Library.Utils.AsposeHelper.ConvertToPlainText(String filename) in C:\Projects\HRNet\Library\Utils\AsposeHelper.cs:line 291
at Dialogs_Candidates_New.ParseFile(TempFileTypes type) in c:\Projects\HRNet\Web\Dialogs\Candidates\New.aspx.cs:line 207
at Dialogs_Candidates_New.toolsUpload_ButtonClick(Object sender, RadToolBarEventArgs e) in c:\Projects\HRNet\Web\Dialogs\Candidates\New.aspx.cs:line 475
at Telerik.Web.UI.RadToolBar.RaiseEvent(Object eventKey, RadToolBarEventArgs e)
at Telerik.Web.UI.RadToolBar.OnButtonClick(RadToolBarEventArgs e)
at Telerik.Web.UI.RadToolBar.RaisePostBackEvent(String eventArgument)
at Telerik.Web.UI.RadToolBar.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
I’ve attached a file that was created from a doc file that was then converted to HTML that was then saved as a doc file that causes the above exception when attempting to save it as plaintext.
The original source file successfully saves as plaintext.
Thanks for any assistance you can provide.
-Stephen