I get this error when I try to convert the attached document to pdf. I use Aspose.Words 9.4.1.0
Code:
Public Shared Function ConvertWordToPDF(ByVal inputFilename As String) As MemoryStream Using inputstream As FileStream = File.Open(inputFilename, FileMode.Open)
Return ConvertWordToPDF(inputstream)
End Using
End Function
Public Shared Function ConvertWordToPDF(ByRef inputStream As Stream) As MemoryStream Dim info As FileFormatInfo = FileFormatUtil.DetectFileFormat(inputStream)
Dim stream As New MemoryStream()
Dim doc As New Document(inputStream)
Dim shapes As NodeCollection = doc.GetChildNodes(NodeType.Shape, True)
' Loop through all shapes.
For Each shape As Shape In shapes
' If shape contains a vector image, convert it to raster image.
If shape.HasImage AndAlso (shape.ImageData.ImageType = ImageType.Wmf OrElse shape.ImageData.ImageType = ImageType.Emf) Then
Using vectorImageStream As New MemoryStream(shape.ImageData.ImageBytes)
Using image As System.Drawing.Image = System.Drawing.Image.FromStream(vectorImageStream)
Using resterImageStream As New MemoryStream()
image.Save(resterImageStream, ImageFormat.Png)
shape.ImageData.SetImage(resterImageStream)
End Using
End Using
End Using
End If
Next
Try
doc.Save(stream, SaveFormat.Pdf)
Catch ex As Exception
doc.Save(stream, SaveFormat.Pdf)
End Try
Return stream
End Function