Converting a TIF document to a PDF document

I followed the example of how to code to convert a TIF to a PDF using the Aspose.Words product and it ran fine. But when I went to open the PDF, I get the message: Adobe Reader could not open ‘1234.pdf’ because it is eather a not supported file type or because the file has been damaged. Is there something else that needs to be done that is not in the code example? I am doing this in a vb.net v2.0(vs2005) program and I used the Aspose Words DLL runtime version v2.0.50727.
Here is my code:

Imports Aspose.Words
Imports Aspose.Words.Drawing
Imports System.IO
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Reflection
Imports Microsoft.VisualBasic
Public Class clsImgConvert
Public Sub ConvertImageToPdf(ByVal inputFileName As String, ByVal outputFileName As String)
Dim fileName As String = "C:\Licenses\Aspose.Total.lic"
Dim fInfo As FileInfo = New FileInfo(fileName)
Dim wordLic As Aspose.Words.License = New Aspose.Words.License()
If fInfo.Exists Then
wordLic.SetLicense(fileName)
End If
' Create Aspose.Words.Document and DocumentBuilder. 
' The builder makes it simple to add content to the document.
Dim doc As New Aspose.Words.Document()
Dim builder As New Aspose.Words.DocumentBuilder(doc)
' Read the image from file, ensure it is disposed.
Using image As Image = image.FromFile(inputFileName)
' Get the number of frames in the image.
Dim framesCount As Integer = image.GetFrameCount(FrameDimension.Page)
' Loop through all frames.
For frameIdx As Integer = 0 To framesCount - 1
' Insert a section break before each new page, in case of a multi-frame TIFF.
If frameIdx <> 0 Then
builder.InsertBreak(BreakType.SectionBreakNewPage)
End If
' Select active frame.
image.SelectActiveFrame(FrameDimension.Page, frameIdx)
' We want the size of the page to be the same as the size of the image.
' Convert pixels to points to size the page to the actual image size.
Dim ps As PageSetup = builder.PageSetup
ps.PageWidth = ConvertUtil.PixelToPoint(image.Width, image.HorizontalResolution)
ps.PageHeight = ConvertUtil.PixelToPoint(image.Height, image.VerticalResolution)
' Insert the image into the document and position it at the top left corner of the page.
builder.InsertImage(image, RelativeHorizontalPosition.Page, 0, RelativeVerticalPosition.Page, 0, ps.PageWidth, ps.PageHeight, WrapType.None)
Next frameIdx
End Using
' Save the document to PDF.
doc.Save(outputFileName)
End Sub
End Class

This message was posted using Page2Forum from How-to: Convert an Image to PDF - Aspose.Words for .NET

Hi

Thanks for your inquiry. Could you please attach your input TIFF and output PDF here for testing? I will check them and provide you more information.
Best regards,

here are the documents for you to look at.

Hello

Thank you for additional information. I cannot reproduce the problem on my side using the latest version of Aspose.Words (9.4.0). Could you please try using the latest version and let me know how it goes on your side.
You can download the latest version from here:
https://releases.aspose.com/words/net
I use the following code for testing:

'Open document
Dim doc As New Document()
Dim builder As New DocumentBuilder(doc)
Dim myImage As Image = Image.FromFile("5053_00023_TITLE.tif")
Dim ps As PageSetup = builder.PageSetup
ps.PageWidth = ConvertUtil.PixelToPoint(myImage.Width, myImage.HorizontalResolution)
ps.PageHeight = ConvertUtil.PixelToPoint(myImage.Height, myImage.VerticalResolution)
builder.InsertImage(myImage, RelativeHorizontalPosition.Page, 0, RelativeVerticalPosition.Page, 0, ps.PageWidth, ps.PageHeight, WrapType.None)
doc.Save("out.pdf")

Best regards,

AndreyN,
thank you for you’re help. I was able to do the converstion using the aspose pdf function instead.