0

I know how to create PDF from TIFFs. My question is: How can itext just embed original TIFFs without modifying them?

I used document.add(img) (where img is the TIFF) to create a PDF. However, the TIFF was modified to smaller size. In this case, my original uncompressed b/w TIFF file size of 2.8 MB was compressed to CCITT Group 4 TIFFs.

Does itext have a way not to modify TIFF?

Y H
  • 1
  • The Jar version is itext-5.5.4 – Y H Feb 18 '15 at 22:08
  • 1
    If you want to *embed original TIFFs without modifying them*, use make them attachments. – mkl Feb 18 '15 at 22:47
  • Another way is to PDF/A-3 to embed arbitrary file in. Of course, others will not know what the arbitary file is unless you have a way to tell. Bruno, does iText support PDF/A standards (PDF/A-1? A-2? A-3?) – Y H Feb 23 '15 at 16:16
  • PDF/A-3 embeds arbitrary files also using file attachments. – mkl Feb 24 '15 at 11:36

1 Answers1

0

Please consult ISO-32000-1. If you read this standard closely, you'll find references to TIFF in the context of LZW and Flate filters, but you'll discover that TIFF is not one of the available filters in PDF. Table 6 shows the options:

enter image description here

As TIFF is not supported in PDF, iText has no other option than to convert it into a format that is accepted. In your case CCITTFaxDecode.

If you really want to keep the TIFF as-is, you need to add it as an attachment. That's explained in my answer to this question: Attaching files to a PDF

Community
  • 1
  • 1
Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
  • Thank you. That is what I thought about. So the output is PNG file. Is there a way to output as JPEG2000 file? – Y H Feb 20 '15 at 02:22
  • 1
    PNG isn't supported by PDF either, so I don't understand why you're saying that the output is a PNG file. What exactly do you mean by "is there a way to output as JPEG2000"? If you want to store a TIFF as a JPEG2000, you should convert the TIFF to a JPEG2000 file first. iText looks at a TIFF and by design makes a choice based on the nature of the TIFF. Some TIFFs are converted so that a `/CCITTFaxDecode` filter is used, others can end up using a `/FlateDecode` or even `/DCTDecode` filter. It all depends on the TIFF. – Bruno Lowagie Feb 20 '15 at 07:20
  • Hi, Bruno, when I ran "pdfReader" and "PdfReaderContentParser" process images, the output format is "png". so is your iText library doing so? – Y H Feb 23 '15 at 16:08
  • That's a design choice. When an image is stored as a compressed bitmap, iText will choose to give you the images as a PNG. However, the `PdfImageObject` also allows you to get the image as a `BufferedImage`, so you can output the image in whichever format your JVM supports. – Bruno Lowagie Feb 23 '15 at 16:24