Question

I'm using iTextSharp to render scanned documents as PDFs. The documents vary in type; they could be jpegs, tiffs or gifs. I fetch them from a web service as byte arrays and use iTextSharp to convert them into PDFs. The issue is that with some of the files I get a "Planar images are not supported" exception. Is this an iTextSharp limitation or is there something else going on that I'm missing? Anyone else come accross this issue?

Was it helpful?

Solution

The TIFF specification is very robust and has many different ways to store image data. The T in TIFF means "tagged" and if you look in the spec for tag 284 you'll find PlanarConfiguration:

1 = Chunky format. The component values for each pixel are stored contiguously ... For example, for RGB data, the data is stored as RGBRGBRGB

2 = Planar format. The components are stored in separate component planes ... For example, RGB data is stored with the Red components in one component plane, the Green in another, and the Blue in another.

PlanarConfiguration=2 is not currently in widespread use and it is not recommend for general interchange. It is used as an extension and Baseline TIFF readers are not required to support it.

iTextSharp has decided to only support the default "chunky format". You can actually see that check and the exception in the source.

I don't know why they chose to not support it (although I can guess it was a combination of lack of samples and also being a pain in the butt) but that's basically what's causing your problems. You could try alternative TIFF parsers that might be able to convert those problematic TIFFs into supported formats.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top