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

Free Support Forum - aspose.com

Conversion from Word Docuiment to PDF using XML Stream - Freezes when saving the PDF

I am using ASPose to convert word documents into PDF documents.

I am running ASPose in trial evaluation mode without a licence.

I have run a bulk conversion of our CVs , using a memory stream to convert the documents to .PDF, the majority of these CVs have converted without any problems.

There are a minority of CVs which appear to be causing the conversion process to hang.

I am running my conversion function ConvertWordDoc (please see code below) from within an ASPX web page under .net framework version 1.1.

The conversion process is converting the word doc to pdf using a memory stream and is being run with the mode parameter set to ConvertWordDocumentMode.ToPDFStream.

The conversion process is freezing when the pdf.save statement is executed.

I have waited up to 20 minutes for this function to finish but it always remains frozen.

On occasions it is returning an IIS out of memory error message which forces me to reboot the web server.

An empty .pdf file of zero size is left after the process is abandoned.

I have attached a sample of one of the documents that is causing the process to freeze.

This document will always cause the process to hang.

I would be grateful if you could investigate and try and replicate this problem.

Thanks in Advance

Chris Hurrell


Public Shared Function ConvertWordDocument(ByVal mode As ConvertWordDocumentMode, ByVal inputfilename As String, ByVal outputfilename As String, ByRef errormessage As String) As String

' Transform document using ASPose

' ---------------------------------

Dim s_save As String

Dim s As String


' Open the DOC file using Aspose.Words.

Dim doc As Aspose.Words.Document = New Aspose.Words.Document(inputfilename)

Select Case mode

Case ConvertWordDocumentMode.ToHTML

' Save the document in htmlformat into a file

doc.Save(outputfilename, SaveFormat.Html)

s_save = outputfilename

Case ConvertWordDocumentMode.ToHTMLString

' Save the document in htmlformat into a memory stream and return as string


Dim stream1 As MemoryStream = New MemoryStream

doc.Save(stream1, SaveFormat.Html)

' Seek to the beginning so it can be read by XmlDocument.

stream1.Seek(0, SeekOrigin.Begin)

Dim tr As New System.IO.StreamReader(stream1)

s_save = tr.ReadToEnd

Case ConvertWordDocumentMode.ToPDFStream

' Save the document in Aspose.Pdf.Xml format into a memory stream.


' Was failing when images present in the word document.

' Changing security permissions on the windows temporary folder has resolved this.

' Images are temporarily saved to windows temporary folder.


Dim stream As MemoryStream = New MemoryStream

doc.Save(stream, SaveFormat.AsposePdf)

' Seek to the beginning so it can be read by XmlDocument.

stream.Seek(0, SeekOrigin.Begin)

' Load the document into an XmlDocument

Dim xmlDoc As XmlDocument = New XmlDocument


' Load the XML document into Aspose.Pdf

Dim pdf As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf

pdf.BindXML(xmlDoc, Nothing)

' Make sure the images that were saved by Aspose.Words into Windows temporary

' folder are automatically deleted by Aspose.Pdf when they are no longer needed.

pdf.IsImagesInXmlDeleteNeeded = True

' Now produce the PDF file.


s_save = outputfilename


stream = Nothing

xmlDoc = Nothing

pdf = Nothing

'Case ConvertWordDocumentMode.ToPDFXML


' ' Save the document in Aspose.Pdf.Xml by using an intermediate xml file

' '----------------------------------------------------------------------


' ' This is failing with the error message whenn saving the .pdf to a mapeed network file

' ' "Logon failure : unknown username of password"

' ' Works ok if saved to local folder.

' 'If we are to use this then need to save to a local folder on the web server.

' '


' Dim s_temporary_xmlfile As String


' s_temporary_xmlfile = Left(outputfilename, Len(outputfilename) - 4) & "_Temp.xml"


' 'You can merge data/manipulate document content here.

' 'Save the document in Aspose.Pdf.Xml format.

' doc.Save(s_temporary_xmlfile, SaveFormat.AsposePdf)


' 'Read the document in Aspose.Pdf.Xml format into Aspose.Pdf.

' Dim pdf As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf

' pdf.BindXML(s_temporary_xmlfile, Nothing)


' 'Instruct to delete temporary image files.

' pdf.IsImagesInXmlDeleteNeeded = True


' 'Produce the PDF file.

' pdf.Save(outputfilename)




' s_save = outputfilename


' pdf = Nothing

End Select

doc = Nothing

errormessage = ""

Catch ex As Exception

errormessage = ex.Message

End Try

Return s_save

End Function

Thank you for considering Aspose.

I have reproduced this error. We will fix it ASAP.

It seems there are some errors in the xml generated by Aspose.Words. We need to contact the Aspose.Words team to fix this problem.

Thanks for your speedy response.

I am glad that you have managed to replicate the problem.

I look forward to a fix for this problem.


Chris Hurrell

Is there a fix available for this problem yet please?


I have tested this document with the latest versions of Aspose.Words and Aspose.Pdf and didn't get the problems you had reported earlier. So the issues have been resolved.