Problem With Aspose.Words unable to convert file created by Aspose.Words

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

Hello

Thanks for your request. I cannot reproduce the problem on my side using the latest version of Aspose.Words (9.7.0).

You can download the latest version from here:

https://downloads.aspose.com/words/net

Best regards,

I can reproduce the problem with 9.7.

It appears it’s because of the PreserveTableLayout setting on the TxtSaveOptions. Our code:

Document doc = new Document(filename);
Aspose.Words.Saving.TxtSaveOptions options = new Aspose.Words.Saving.TxtSaveOptions();
// options.PrettyFormat = true;
options.PreserveTableLayout = true;
doc.Save(temppath, options);

If I disable PreserveTableLayout it behaves properly. If I enable it, it fails with the exception in the previous post. (I disabled PrettyFormat during the process to help isolate the problem.)

Hello

Thank you for reporting this problem to us and for the additional information. I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is fixed.

Best regards,

A fix for the issue(s) you've reported (filed as 24342) will be released in the next release at the end of this month.


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

The issues you have found earlier (filed as WORDSNET-4416) have been fixed in this .NET update and in this Java update.


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