We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Only one page of multipage tif is converted

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



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


Return 1

Catch ex As Exception

ErrorMessage += ex.Message

Return -1

End Try

End Function


Please use the following statement to include all pages.

image1.ImageInfo.TiffFrame = -1



Thanks for the response. However, the suggestion you provided resulted in a strange behavior. I tried

image1.ImageInfo.TiffFrame = -1

as suggested and the resulting PDF did indeed capture all the pages of the mult-page tiff. But the problem is, when I opened the PDF file, Acrobat simply displayed each page for a second goes to the next page and the next and the next, similar a slideshow, until the very last page, where it stops permanently. Acrobat shows the PDF file as a one-page file, so I have no way to navigate forwards or backwards. Is there a way to convert a multi-page image file to a mult-page PDF?

Attached is the resulting PDF file when I tried the TiffFrame = -1 code.



I played around and found the solution. I simply used:

image1.ImageInfo.IsAllFramesInNewPage = True

and it worked.