Free Support Forum - aspose.com

Aspose.Words not converting some older MS Word documents

Hello,

I have come across this issue where we have some old MS Word documents (created back in 2007) that when converted are coming across as blank pages when we concatenate documents with (pdfEditor.Concatenate.) However if I open the document(s) and save it with Word 2007 as a “Word 97-2003 Document’ the file will convert and be appended correctly. Do you have any solutions on how to fix this issue? We are currently using the latest version of your product (Aspose Total) Note: I will not be able to send you the document(s) which have the issues due to internal policies.

Here is our function for converting the document:

Private Function ConvertWord(ByVal docStream As MemoryStream) As MemoryStream
Dim pdfStream As MemoryStream = Nothing

Try
Dim doc As New Aspose.Words.Document(docStream)
pdfStream = New MemoryStream
doc.Save(pdfStream, SaveFormat.Pdf)

Catch ex As Exception
'Throw New Exception(”[" & MethodBase.GetCurrentMethod().ToString() & "] " & ex.Message, ex)
Throw New Exception(“Error Converting the Word Document to a PDF.”)
End Try

Return pdfStream
End Function


Here is our Merge function:

Private Function MergePDFs(ByVal pdfStreams() As MemoryStream) As MemoryStream
Dim destPdfStream As MemoryStream

If pdfStreams.Count = 1 Then

pdfStreams(0).Position = 0
destPdfStream = pdfStreams(0)
ElseIf pdfStreams.Count > 1 Then
'Aspose PdfFileEditor in Aspose version v4.3.0.0 closes the stream - need to get a patched dll
'http://www.aspose.com/community/forums/2/230644/v4.3.0.0-pdffileeditor.concatenate-closes-memorystream/showthread.asp
'Version 4.8.x.x fixes the closed stream issue;
'For Each docstream In pdfStreams
’ docstream.Position = 0
'Next

destPdfStream = New MemoryStream
destPdfStream.Position = 0
Dim pdfEditor As New PdfFileEditor()


pdfEditor.Concatenate(pdfStreams, destPdfStream)
Else
Throw New ArgumentException(“No streams provided to merge”, “pdfStreams”)
End If

Return destPdfStream

End Function

Thanks Matt

Hello

Thanks for your request. Unfortunately, it is difficult to say what the reason of the problem is without the document. I need this document to reproduce the problem on my side.

It is safe to attach files in the forum. If you attach your document here, only you and Aspose staff members can download it. Moreover, you can make this thread private. In this case, nobody except you and Aspose staff will be able to see this thread.

Also you can send the file to my e-mail as described here:

http://www.aspose.com/corporate/purchase/faqs/send-license-to-aspose-staff.aspx

You can also remove any sensitive information by replacing it with dummy data instead.

Best regards,

AndreyN:

Hello

Thanks for your request. Unfortunately, it is difficult to say what the reason of the problem is without the document. I need this document to reproduce the problem on my side.

It is safe to attach files in the forum. If you attach your document here, only you and Aspose staff members can download it. Moreover, you can make this thread private. In this case, nobody except you and Aspose staff will be able to see this thread.

Also you can send the file to my e-mail as described here:

http://www.aspose.com/corporate/purchase/faqs/send-license-to-aspose-staff.aspx

You can also remove any sensitive information by replacing it with dummy data instead.

Best regards,



I did some more digging into this problem and noticed that the documents are coming through a redirect we have in place. For a test I put in the direct URL to the document and it worked.

Dim filepath As String = dr.Item("FILEPATH")
Dim filename As String = dr.Item("FILENAME")
Dim docextension As String = GetExtension(filename)

'Dim FileData As Byte() = File.ReadAllBytes(filepath)
Dim FileRequest As WebRequest
Dim response As WebResponse = Nothing
Dim uri As New Uri(String.Format(filepath))
FileRequest = WebRequest.Create(uri)
FileRequest.Timeout = 10000
FileRequest.Credentials = CredentialCache.DefaultCredentials
response = FileRequest.GetResponse

s = response.GetResponseStream

Dim read(256) As Byte
Dim count As Int32 = s.Read(read, 0, read.Length)
file = New MemoryStream
Do While (count > 0)
file.Write(read, 0, count)
count = s.Read(read, 0, read.Length)
Loop
file.Position = 0
'Close responsestream
s.Close()
response.Close()

Hello

It is perfect, that you already found solution. Please let me know in case of any issues. I will be glad to help you.

Best regards,