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

Free Support Forum - aspose.com

Document Save is hanging and consuming all CPU

We have an issue with a document saving. In the code snippet below this line hangs forever
inDocument.Save(oStream, oOptions)

I need a solution to this! I am using version 20.12.0

Private Function pf_ConvertDoc(ByVal inDocument As Document, ByVal inSaveFormat As SaveFormat) As String
    Dim sResult As String = String.Empty

    If (Not inDocument Is Nothing) Then
        Dim oStream As Stream = Nothing
        Dim oReader As StreamReader = Nothing

        oStream = New MemoryStream()

        Try
            If (inSaveFormat = SaveFormat.Html) Then
                Dim oOptions As Saving.HtmlSaveOptions = New Saving.HtmlSaveOptions(SaveFormat.Html)
                oOptions.ExportImagesAsBase64 = True
                inDocument.Save(oStream, oOptions)
            Else
                inDocument.Save(oStream, inSaveFormat)
            End If

            oStream.Position = 0

            oReader = New StreamReader(oStream)
            sResult = oReader.ReadToEnd()
        Catch
            sResult = String.Empty
        Finally
            If (Not oStream Is Nothing) Then
                oStream.Close()
                oStream.Dispose()
            End If

            If (Not oReader Is Nothing) Then
                oReader.Close()
                oReader.Dispose()
            End If
        End Try
    End If

    Return sResult
End Function

Just to clarify, it doen’t happen with every document. Just ones with strange characters in.

It is a .docx

@networx Could you please attach the problematic document here for testing? We will check the issue and provide you more information. Unfortunately, it is impossible to analyze the problem without your document.

Please find attached documentRedacted Test CV.docx (50.8 KB)

@alexey.noskov document uploaded above

@networx Thank you for additional information. Unfortunately, I cannot reproduce the problem using the latest 22.5 version of Aspose.Words. I used the following simple code for testing:

Document doc = new Document(@"C:\Temp\in.docx");
using (MemoryStream outputStream = new MemoryStream())
{
    HtmlSaveOptions oOptions = new HtmlSaveOptions(SaveFormat.Html);
    oOptions.ExportImagesAsBase64 = true;
    doc.Save(outputStream, oOptions);
}