HTMLExport.SaveAsXhtml() hangs

Hi there, using the latest DocIO (20.3.0.47) under .NET 4.8, C#8.0, HTMLExport.SaveAsXhtml() hangs when trying to save the attached document. Memory consumption varies periodically forever:


As this process is sync, how can I timeout it?

Please advise.  Thanks.

Code is nothing special:

WordDocument document = new WordDocument( rtfStream, FormatType.Rtf );

                HTMLExport export = new HTMLExport();

                //The headers and footers in the input are exported

                document.SaveOptions.HtmlExportHeadersFooters = false;

                //Exports the text form fields as editable

                document.SaveOptions.HtmlExportTextInputFormFieldAsText = false;

                //Sets the style sheet type

                document.SaveOptions.HtmlExportCssStyleSheetType = CssStyleSheetType.Internal;

                //Export the Word document image as Base-64 embedded image

                document.SaveOptions.HTMLExportImageAsBase64 = true;

                //Saves the document as html file

                using MemoryStream htmlStream = new MemoryStream();

                export.SaveAsXhtml(document, htmlStream, Encoding.UTF8);

                document.Close();





Attachment: 82014HU2205PIJ020476_f355f3bb.ZIP

7 Replies

GG Gyorgy Gorog September 29, 2022 11:26 AM UTC

I am unable to cancel this task properly. This helps but is not a good way, the task remains in Running state, despite the Cancel().

using MemoryStream htmlStream = new MemoryStream();

                using CancellationTokenSource tokenSource = new CancellationTokenSource(1000 * (int)Settings.Default.OcrTimeOutSecs);

                CancellationToken token = tokenSource.Token;

                Task task = Task.Run(() =>

                {

                    export.SaveAsXhtml(document, htmlStream, Encoding.UTF8);

                    return true;

                }

                , token);


                Task.Delay(100).Wait();

                if (task.Status != TaskStatus.Running)

                    task.Start();


                int secs = 0;

                while ( ++secs < Settings.Default.OcrTimeOutSecs && !task.IsCompleted)

                    Task.Delay(100).Wait();


                if (token.CanBeCanceled)

                    tokenSource.Cancel();

                document.Close();


                if (task.Status != TaskStatus.RanToCompletion ) return false;



AN Anto Nihil Sahaya Raj Syncfusion Team September 30, 2022 08:07 AM UTC

Hi Gyorgy,

We have reproduced the reported issue Hanging occurs while customizing the RTF to HTML conversion(HTMLExport.SaveAsXhtml())”
in our end, and we suspect it to be a defect. We will validate this issue and update you with more details on 04th October 2022.

Regards,
Anto Nihil S



GG Gyorgy Gorog September 30, 2022 09:15 AM UTC

Anto, thanks for the update. Most worrying is that the process cannot be cancelled. Please consider an async version. Thanks.



AA Akash Arul Syncfusion Team October 4, 2022 02:34 PM UTC

Hi Gyorgy,

We have confirmed that reported issue Hanging issue occurs due to tab position while converting a RTF document to HTMLis a defect and we have logged a defect report. We will include the fix for this defect in our weekly NuGet release which is estimated to be available on 25th October 2022.

The status of this bug can be tracked through the below link:
https://www.syncfusion.com/feedback/38175/hanging-issue-occurs-due-to-tab-position-while-converting-a-rtf-document-to-html

Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.”

Regards,
Akash A



AA Akash Arul Syncfusion Team October 26, 2022 12:07 PM UTC

Hi Gyorgy,

Due to the release holiday, we have postponed the weekly release to tomorrow. We will let you know once it is rolled out.

Regards,
Akash A.



AA Akash Arul Syncfusion Team October 27, 2022 01:09 PM UTC

Hi Gyorgy,

As promised earlier, we have included the fix for the reported issue with “Hanging issue occurs due to tab position while converting a RTF document to HTML” in our latest weekly NuGet release (v20.3.0.52).

Please use the below link to download our latest weekly NuGet:
https://www.nuget.org/packages/Syncfusion.DocIO.WinForms/20.3.0.52

The status of this bug task can be tracked through the below link:
https://www.syncfusion.com/feedback/38175/hanging-issue-occurs-due-to-tab-position-while-converting-a-rtf-document-to-html

Note: We will include this fix in our 2022 Volume 3 service pack release which will be available in mid of November 2022.

Regards,
Akash A.



GG Gyorgy Gorog November 7, 2022 07:44 PM UTC

Akash, thanks for fixing this. I can confirm this problem is fixed. Still, I would prefer it be cancelable. Thanks!


Loader.
Up arrow icon