Problems rendering Tiff Images to PDF


I’m having issues with a large number of TIFF files not rendering to PDF. Each of them fails with an exception:

"Unable to read file. Exception: Specified argument was out of the range of valid values.\r\nParameter name: codec not supported - Codec #Packbits"

Looking at the file (sample attached), it does use Packbits:

.\tiffinfo \Temp\1.TIF
TIFF Directory at offset 0x8 (8)
Image Width: 2385 Image Length: 1587
Resolution: 300, 300
Compression Scheme: CCITT Group 4
Photometric Interpretation: min-is-white
Rows/Strip: 1587
Planar Configuration: single image plane
Model: Canon DR-9080C
Software: Onstream Trapeze 8.34
DateTime: 2011:12:21 15:16:45
TIFF Directory at offset 0xa224 (41508)
Subfile Type: reduced-resolution image (1 = 0x1)
Image Width: 128 Image Length: 85
Resolution: 16.1006, 16.0681
Bits/Sample: 8
Compression Scheme: PackBits
Photometric Interpretation: min-is-white
Rows/Strip: 85
Planar Configuration: single image plane
Software: Onstream Trapeze 8.34

I noticed the following item in the April release of the Imaging 2.9 component:

IMAGING-33575 TIFF Codec does not support PackBits compression method

Is there any chance of Packbits support being extended to the Aspose.PDF product?

Hi Tony,

Thanks for your inquiry. I have tested the scenario using new DOM approach for Image to PDF conversion with Aspose.Pdf for .NET 10.7.0 and unable to notice the reported issue. Please use DOM approach it will resolve the issue.

Please feel free to contact us for any further assistance.

Best Regards,

Thanks for the quick reply - We will give it a go and let you know if we have any problems.

Hi - We tried the code suggested and whilst it worked for a single page image, it’s a bit too simplistic for us.

Our TIFF images are usually multi-page and often a mix of portrait and landscape pages in the same document.

We previously used the Aspose.Imageing.Image.Load call to load the Tiff image and then iterated through the frames to determine the page layout etc. The frames are then added individually to the PDF object.

This Aspose.Imageing.Image.Load call is the one one throwing the exception.

The demo code only looks at the bitmap from the first page, so it won’t help.

Do you have better sample code or a different method to access each page in the Tiff?


Happy to provide sample images if required.

Hi Tony,

Thanks for your inquiry. We will appreciate it if you please share your sample code and document here, we will look into it and guide you accordingly.

Best Regards,

Here’s our code and a sample image It’s a large one, but that might be part of the issue.

Hi Tony,

Thank you for sharing the sample image.

In a previous response, you have mentioned that Aspose.Imaging.Image.Load method throws the said exception, however, when we tested the load operation while using the latest version of Aspose.Imaging for .NET 3.0.0, we were not able to observe any exception. Moreover, your provided code file is of 0 bytes in size therefore we have tested the frame splitting operation using the following piece of code and found no issues. Please check the attached archive for the resultant images.

In case you are using any older revision of Aspose.Imaging for .NET we suggest you to upgrade the API to 3.0.0 and retest the scenario on your side. If the problem persists even after upgrading the Aspose.Imaging for .NET API, please provide the code (covering your complete scenario) or a sample application with required input document(s) for further investigation in this regard.


TiffImage image = (TiffImage)Image.Load(“D:/testimage.tif”);
int index = 0;
foreach (TiffFrame frame in image.Frames)
frame.Save(“D:/output” + index++ + “.tiff”, new TiffOptions(TiffExpectedFormat.TiffLzwBW));

Thanks -The upgrade to V3 of Aspose Imaging fixed the Image.Load problem.

The code now fails with an exception when saving the resulting PDF file.

Sample standalone app attached as a text file.

Hi Tony,

When using legacy Aspose.Pdf.Generator (as shared in your code snippet) to insert TIFF image inside PDF file, I encountered an exception. However as recommended earlier, please try using new Document Object Model (DOM) for TIFF to PDF conversion but during my testing, I have observed that an OutOfMemoryException is being generated when converting TIFF image to PDF file. For the sake of correction, I have logged this problem
as PDFNEWNET- 39347 in our issue tracking system. We will further
look into the details of this problem and will keep you updated on the status
of correction. Please be patient and spare us little time. We are sorry for
this inconvenience.


FileStream fs = new FileStream("c:/pdftest/TestImage.TIF", FileMode.Open, FileAccess.Read);
byte[] tmpBytes = new byte[fs.Length];
fs.Read(tmpBytes, 0, Convert.ToInt32(fs.Length));
MemoryStream mystream = new MemoryStream(tmpBytes);
// Instantiate BitMap object with loaded image stream
Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(mystream);
var pdf = new Aspose.Pdf.Document();
pdf.PageInfo.Height = (float)Math.Ceiling(Aspose.Words.ConvertUtil.PixelToPoint(image.Height, 96.0) + pdf.PageInfo.Margin.Top + pdf.PageInfo.Margin.Bottom);
pdf.PageInfo.Width = (float)Math.Ceiling(Aspose.Words.ConvertUtil.PixelToPoint(image.Width, 96.0) + pdf.PageInfo.Margin.Left + pdf.PageInfo.Margin.Right);
var section = pdf.Pages.Add();
var pdfImage = new Aspose.Pdf.Image();
var tiffImage = image as Aspose.Imaging.FileFormats.Tiff.TiffImage;
string tempPath = "c:/pdftest/TestImage_temp.TIF";
File.Copy("c:/pdftest/TestImage.TIF", tempPath, true);
for (int i = 0; i < tiffImage.Frames.Length; i++)
    var frame = tiffImage.Frames[i];
    Aspose.Pdf.Image framePdfimage;
    Aspose.Pdf.Page frameSection;
    if (i == 0)
        framePdfimage = pdfImage;
        frameSection = section;
        frameSection = pdf.Pages.Add();
        //frameSection.IsNewPage = true;
        framePdfimage = new Aspose.Pdf.Image();
    if (frame.Height > 0 && frame.Width > 0)
        var frameHeight = (float)Aspose.Words.ConvertUtil.PixelToPoint(frame.Height, (frame.VerticalResolution > 0 ? frame.VerticalResolution : 96.0));
        var frameWidth = (float)Aspose.Words.ConvertUtil.PixelToPoint(frame.Width, (frame.HorizontalResolution > 0 ? frame.HorizontalResolution : 96.0));
        frameSection.PageInfo.Height = frameHeight + frameSection.PageInfo.Margin.Top + frameSection.PageInfo.Margin.Bottom;
        frameSection.PageInfo.Width = frameWidth + frameSection.PageInfo.Margin.Left + frameSection.PageInfo.Margin.Right;
        framePdfimage.FixHeight = frameHeight;
        framePdfimage.FixWidth = frameWidth;
        framePdfimage.ImageScale = 1.0F;
    framePdfimage.File = tempPath;
    //framePdfimage.TiffFrame = i;
using (var pdfMs = new MemoryStream())
    var filestream = new FileStream("c:/pdftest/TestImage.pdf", FileMode.Create);

Hi - Any update on this fix?

I noticed that 3.1.0 has been released and was hoping that this might be resolved.


Hi Tony,

Thanks for your inquiry. Please note your reported issue(PDFNEWNET-39347) is Aspose.Pdf related issue and it has to be fixed in Aspose.Pdf for .NET. Your reported issue is still not resolved as we have recently noticed it. It is pending for investigation in the queue with other issues. We will notify you as soon as we made some significant progress towards issue resolution.

We are sorry for the inconvenience caused.

Best Regards,

Wondering if there is any update on issue PDFNEWNET-39347?

Hi Tony,

Thanks for your inquiry. I am afraid your above reported issue is still not resolved as product team is busy in resolving other issues in the queue, reported earlier. However I have raised your issue priority and requested our team to share an ETA at their earliest. We will notify you as soon as we made some significant progress towards issue resolution.

We are sorry for the inconvenience caused.

Best Regards,

The issues you have found earlier (filed as PDFNET-39347) have been fixed in Aspose.PDF for .NET 18.11.