Sample code to Convert Multipage TIF to PDF

Hi Support,

We are on version 11 Aspose Total, apose.pdf 6.6

Hi I have checked the forum and tried the examples but they don't work. We are using a memory stream containing the multipage tif and are creating the pdf, but only the first page can be seen in the resultant pdf. Do you have a sample that works.

Thanks

Clive

Hi Clive,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for contacting support.

Well, you may try setting Image.ImageInfo.TiffFrame = -1 to allow adding all the Tiff Frames to PDF file. As Tiff is a multiframe image, so you can use this property to set the frame to be converted (-1 means all and by default it is 0). Please see the following sample code in this regard.

//Instantiate a Pdf object by calling its empty constructor

Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

//Create a section in the Pdf object

Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

// Create a FileStream object to read the imag file

FileStream fs = File.OpenRead("E:/AP Data/Jan2012/101_268.tif");

// Read the image into Byte array

byte[] data = new byte[fs.Length];

fs.Read(data, 0, data.Length);

// Create a MemoryStream object from image Byte array

MemoryStream ms = new MemoryStream(data);

//Create an image object in the section

Aspose.Pdf.Generator.Image image1 = new Aspose.Pdf.Generator.Image(sec1);

//Set the path of image file

/ image1.ImageInfo.File = "E:/AP Data/Jan2012/101_268.tif";

//Set the type of image using ImageFileType enumeration

image1.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Tiff;

image1.ImageInfo.TiffFrame = -1;

// Specify the image source as MemoryStream

image1.ImageInfo.ImageStream = ms;

//Set image title

image1.ImageInfo.Title = "Multi Page Tiff";

//Add image object into the Paragraphs collection of the section

sec1.Paragraphs.Add(image1);

//Save the Pdf

pdf1.Save("E:/AP Data/Feb2012/Tiff_test.pdf");

// Close the MemoryStream Object

ms.Close();

If you still face any issue, please share your sample code and template file with us. This will help us figure out the issue soon.

Thank You & Best Regards,

Hi Clive,


Thanks for using our products.

Adding more to Nausherwan’s comments, you may consider checking out the following links for more details on
In the event of any further query, please feel free to contact. We are really sorry for your inconvenience.