Free Support Forum -

Copying multiple Tiff Frame to Aspose Document

I have multiple Tiff Files that I am converting to pdf files. To begin, These Tiff files can come in as scanned or uploaded and can be a number of different sizes.

The first thing I do is foreach through the TiffFrames, check the size of them, and adjust the size of the document page to either Legal, Letter, or Landscape. I then want to adjust the TiffFrame to fit this page.

I am trying to adjust the TiffFrame and place each frame onto a single page of the document after the size has been set.

I know the way to directly convert the Tiff to pdf, but I do not see a way to make these modifications and then manually add each from to its own page afterwards.


We hope that the below code will help you in achieving you require. Please feel free to let us know in case you still face any issue:

Document pdf1 = new Document();

FileStream ms = new FileStream(dataDir + "Page_1_2_3.tiff", FileMode.Open);
Bitmap myimage = new Bitmap(ms);
FrameDimension dimension = new FrameDimension(myimage.FrameDimensionsList[0]);
int frameCount = myimage.GetFrameCount(dimension);

for (int frameIdx = 0; frameIdx <= frameCount - 1; frameIdx++)
 Page sec = pdf1.Pages.Add();
 myimage.SelectActiveFrame(dimension, frameIdx);
 MemoryStream currentImage = new MemoryStream();
 myimage.Save(currentImage, ImageFormat.Tiff);
 if (myimage.Width > myimage.Height)
  sec.PageInfo.IsLandscape = true;
  sec.PageInfo.IsLandscape = false;
 sec.PageInfo.Margin = new MarginInfo(0, 0, 0, 0);
 sec.PageInfo.Height = myimage.Height;
 sec.PageInfo.Width = myimage.Width;
 Aspose.Pdf.Image imageht = new Aspose.Pdf.Image();
 imageht.ImageStream = currentImage;
pdf1.Save(dataDir + "TifftoPDF.pdf");

This works great but we will still need to do some thorough testing. I appreciate your fast response!


Sure, please take your time to test the scenario and feel free to let us know in case you need more assistance.

1 Like