I have a multi-page tif file of which APSOSE.PDF only converts the first page. I have attached the original tif file. The function I wrote to convert images is below.
Public Function ConvertImage(ByVal SourceFilePath As String, ByVal NewFilePath As String, ByRef ErrorMessage As String) As String
Dim ImageFile As FileInfo
'Instantiate a Pdf object by calling its empty constructor
Dim pdf1 As Pdf = New Pdf()
'Create a section in the Pdf object
Dim sec1 As Aspose.Pdf.Section = pdf1.Sections.Add()
'Create an image object in the section
Dim image1 As Aspose.Pdf.Image = New Aspose.Pdf.Image(sec1)
'Add image object into the Paragraphs collection of the section
sec1.Paragraphs.Add(image1)
Try
ImageFile = New FileInfo(SourceFilePath)
'Set the path of image file
image1.ImageInfo.File = SourceFilePath
'Set the type of image using ImageFileType enumeration
Select Case LCase(ImageFile.Extension)
Case ".bmp"
image1.ImageInfo.ImageFileType = ImageFileType.Bmp
Case ".gif"
image1.ImageInfo.ImageFileType = ImageFileType.Gif
Case ".ico"
image1.ImageInfo.ImageFileType = ImageFileType.Icon
Case ".png"
image1.ImageInfo.ImageFileType = ImageFileType.Png
Case ".tif", ".tiff"
image1.ImageInfo.ImageFileType = ImageFileType.Tiff
image1.PositioningType = PositioningType.PageRelative
Case ".jpg"
image1.ImageInfo.ImageFileType = ImageFileType.Jpeg
Case Else
'Do Nothing. Not a supported image type
image1.ImageInfo.ImageFileType = ImageFileType.Unknown
End Select
'Set image title
'image1.ImageInfo.Title = "JPEG image"
'Save the Pdf
pdf1.Save(NewFilePath)
Return 1
Catch ex As Exception
ErrorMessage += ex.Message
Return -1
End Try
End Function