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

Free Support Forum - aspose.com

Converting color TIF files to PDF create a huge file

Having tif files B&W and convert to PDF file, generates a huge PDF file.
But, if you set the flag as follow, the problem is fixed
image.IsBlackWhite = true;

Having tif files Color and convert to PDF file, generates a huge PDF file
30 tif files of 66 KB each one, create 18 MG pdf file
Is there a way to make the pdf smaller?


After converting and saving the final PDF document, you may please try to optimize its size which will compress the images and reduce the file size. In case you still notice any issue, please share the sample input TIFF image along with sample code snippet with us. We will test the scenario in our environment and address it accordingly.

Here is the example file ColorImage_P01.zip (62.7 KB)

you can copy multiple times this image, to have X number of tif files (I have 30 tif files)


Please also share the sample code snippet that you are using to add TIFF inside PDF. This will allow us to test the scenario accordingly.

Here it is

private void AddImageToNewPage(string sourceImageFile, Document doc)
using (var ms = new MemoryStream())
using (var sourceFileStream = new FileStream(sourceImageFile, FileMode.Open))

                var myImage = new Bitmap(ms);
                // Convert multi page or multi frame TIFF to PDF
                var dimension = new FrameDimension(myImage.FrameDimensionsList[0]);
                var frameCount = myImage.GetFrameCount(dimension);

                // Iterate through each frame
                for (var frameIdx = 0; frameIdx <= frameCount - 1; frameIdx++)
                    var page = doc.Pages.Add();
                    myImage.SelectActiveFrame(dimension, frameIdx);
                    var currentImage = new MemoryStream();
                    myImage.Save(currentImage, ImageFormat.Tiff);
                    var image = new Aspose.Pdf.Image { ImageStream = currentImage };

                    if (IsABlackAndWhiteImage(myImage))
                        image.IsBlackWhite = true;


    public bool IsABlackAndWhiteImage(Bitmap myImage)
        var isBlackAndWhite = myImage.PixelFormat == PixelFormat.Format1bppIndexed;
        return isBlackAndWhite;


Please check the below code snippet that we used along with optimizing the PDF while testing the scenario.

Document pdf1 = new Document();
var files = Directory.GetFiles(dataDir + "images\\", "*.tif");
foreach (var file in files)
 FileStream ms = new FileStream(file, 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");
var oo = new Aspose.Pdf.Optimization.OptimizationOptions();
oo.ImageCompressionOptions.ImageQuality = 50;
oo.ImageCompressionOptions.MaxResolution = 144;
oo.ImageCompressionOptions.ResizeImages = true;
oo.ImageCompressionOptions.CompressImages = true;
oo.ImageCompressionOptions.Version = Aspose.Pdf.Optimization.ImageCompressionVersion.Fast;
oo.RemoveUnusedObjects = true;
oo.RemoveUnusedStreams = true;
oo.LinkDuplcateStreams = true;
oo.SubsetFonts = true;
oo.AllowReusePageContent = true;
oo.UnembedFonts = true;
using (Document document = new Document(dataDir + "TifftoPDF.pdf"))
 document.OptimizeSize = true;
 document.Save(dataDir + "output" + DateTime.Now.Millisecond + ".pdf");

We obtained a document with 235KB size that is also attached for your kind reference. output892.pdf (234.5 KB)

Would you please try using the above shared code snippet with 21.11 version of the API and let us know in case you face any issues.