I want to add image to pdf file. I’m using iTextSharp for this.
I have the following code:
var imageBanner = iTextSharp.text.Image.GetInstance(bannerImagePath);
The problem in that the RawData property is equal NULL for jpg images, but for png is all ok.
Please read chapter 10 of the book “iText in Action”. The
Imageclass is abstract. It has different implementations for different image types. Some image types exist in PDF. For instance: a JPG (DCTDecode) can be copied literally into a PDF. File types such as PNG and GIF don’t exist in PDF, so they need to be converted toraw datafirst; they are compressed (FlateDecode) later on in the process.As there’s absolutely no need for any ‘processing’ when dealing with JPGs, no memory is wasted on creating a raw image. It would be bad if
RawDataweren’tnull, hence my question: why is it a problem for you? you should be happy thatRawDataisnull!