Timeout Error Converting Word To PDF

Private Function PDFConverion(ByRef WordPath As String, ByRef PDFPath As String, ByRef waitTime As Short) As Boolean

Dim result As Boolean = False

Dim ConversionComplete As Boolean = False

Dim WordsLicense As New Aspose.Words.License

WordsLicense.SetLicense("Aspose.Total.lic")

Dim PdfLicense As New Aspose.Pdf.License

PdfLicense.SetLicense("Aspose.Total.lic")

Try

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

Dim xmlFileName As String = Mid(WordPath, 1, InStr(WordPath, ".") - 1) & ".xml"

'Save the document in Aspose.Pdf.Xml format

doc.Save(xmlFileName, Aspose.Words.SaveFormat.AsposePdf)

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

Dim pdf As New Aspose.Pdf.Pdf

pdf.BindXML(xmlFileName, Nothing)

'delete temporary image file

pdf.IsImagesInXmlDeleteNeeded = True

'code to speed up conversion

pdf.IsTruetypeFontMapCached = True

pdf.TruetypeFontMapPath = System.IO.Path.GetTempPath()

Dim objRandomGenerator As New Random

PDFPath = _TempFolder & objRandomGenerator.Next(System.Int32.MaxValue) & ".PDF"

'produce the pdf file

pdf.Save(PDFPath)

'check the pagecount property - greater than zero means the conversion is complete.

Do While Not ConversionComplete

If pdf.PageCount > 0 Then

ConversionComplete = True

End If

Loop

result = True

Catch ex As Exception

Throw ex

result = False

End Try

Return result

End Function

I am getting a timeout error when this code is run on our production server. It runs fine on our test server. Originally I had use the Thread.Sleep function to wait 45 seconds to make sure the conversion is complete but I modified the code to try and speed the conversion up. Any ideas?

Hello Curtis,

Thanks for considering Aspose.

As far as I can understand the problem might be due to the size of the input word file. The conversion process is taking time due to the contents of the word document. Can you please share the resource word file so that we can test the scenario at our end.

Beside, can you please share that you are facing this problem every time you start the conversion process or its only occurring on first time.

We apologize for your inconvenience.

I’m attaching 2 types of files that are converted. The code is part of a web service that is called from the main application. This is happening everytime the conversion process starts.

Hello Curtis,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

The query has been replied over 190632. In case you still have any further query, please feel free to contact.