I
I
iText Software2019-06-26 11:12:57
Java
iText Software, 2019-06-26 11:12:57

What types of images does iText support?

I want to add a PNG image to a PDF file, but I know that PDF does not support PNG files.
Does this mean I can't use PNG files in iText?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
iText Software, 2019-06-26
@iText_Q

. iText supports JPEG, JPEG2000, GIF, PNG, BMP, WMF, TIFF, CCITT, and JBIG2 image formats. This does not mean that these image types are also supported in PDF. If a certain image type (such as PNG) is not supported in PDF, iText will convert it to the image type defined in the PDF specification.
•JPEG images are stored in iText in their original form. You can take the streaming contents of an Image XObject in JPEG format, copy it to a file, and you have a proper JPEG image. The following filter recognizes these images: /DCTDecode.
•JPEG2000 format is supported from PDF version 1.5. The name of the filter is JPXDecode.
•PDF supports images with LZW compression (used for GIFs), but iText decodes GIFs to RAW images. If you create an Image using iText and specify the path to the GIF file, then the PDF file will get an image with the /FlateDecode filter.
• PNG images are not supported in PDF files, so iText decodes PNG images to RW. If the image's color space is DeviceGray and has 1 bit per component, then the CCITT compression method and /CCITTFaxDecode filter will be used. Otherwise, the /FlateDecode filter will be used.
•BMP files are stored in a group of compressed pixels using the /FlateDecode filter.
• With the WMF format, the situation is special. If you insert a WMF file into a PDF document using iText, iText will convert the image to PDF syntax. iText will create a Form XObject instead of adding an Image XObject.
• When image data is encoded using the CCITT facsimile standard, the /CCITTFaxDecode filter is used. These are usually monochrome images with one bit per pixel.
•In addition, TIFF files can be processed in iText. Depending on the settings of the TIFF files, iText decides to use /CCITTFaxDecode, /FlateDecode, or even /DCTDecode as a filter.
• For JBIG2, the /JBIG2Decode filter is used.
Usually, there are no difficulties with the image format. The Image class itself chooses the correct compression method.
Additional Information. PDF files support transparency, however it is worth remembering that transparent images are not supported in PDF. One image containing transparent areas can be converted into two different images.
1. Opaque image.
2. Image mask.
All this happens in the PDF file itself. If you add a transparent image to a PDF file, you won't be able to export it from there. You will have to upload two images: an opaque version and a mask.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question