Title: Nachricht
That's a very old way. See the example read_tiffs.java at itextpdf.sf.net.
 
Best Regards,
Paulo Soares


From: Dr. Stefan Reisner [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 28, 2004 5:38 PM
To: Paulo Soares
Subject: AW: [iText-questions] (no subject)

Hello Paulo,
 
here's the code:
 
 public byte[] convert(byte[] src) throws FSMException {
  Document document = new Document(PageSize.A4);
  float usableWidth = document.right()-document.left();
  float usableHeight = document.top()-document.bottom();
  
  ByteArrayOutputStream bout = new ByteArrayOutputStream();
 
  byte[] result = null;
 
  try {     
      PdfWriter writer = PdfWriter.getInstance(document,bout);
      writer.setEncryption(PdfWriter.STRENGTH40BITS, null, null, PdfWriter.AllowPrinting | PdfWriter.AllowScreenReaders | PdfWriter.AllowCopy);
      ByteArraySeekableStream in = new ByteArraySeekableStream(src);
       
      TIFFDirectory dir = new TIFFDirectory(in,0);
      long IFDOffset = dir.getIFDOffset();
      document.open();
      PdfContentByte cb = writer.getDirectContent();
       
      while(IFDOffset != 0L) {
       dir = new TIFFDirectory(in, IFDOffset, 0);
          IFDOffset = dir.getNextIFDOffset();
          long h = dir.getFieldAsLong(TIFFImageDecoder.TIFF_IMAGE_LENGTH);
          long w = dir.getFieldAsLong(TIFFImageDecoder.TIFF_IMAGE_WIDTH);
          long offset = dir.getFieldAsLong(TIFFImageDecoder.TIFF_STRIP_OFFSETS);
          long size = dir.getFieldAsLong(TIFFImageDecoder.TIFF_STRIP_BYTE_COUNTS);
          boolean reverse = false;
          if (dir.isTagPresent(TIFFImageDecoder.TIFF_FILL_ORDER)) {
              reverse = (dir.getFieldAsLong(TIFFImageDecoder.TIFF_FILL_ORDER) == 2L);
          }
          
          int compression = (int)dir.getFieldAsLong(TIFFImageDecoder.TIFF_COMPRESSION);
          
          switch (compression) {
              case TIFFImage.COMP_FAX_G3_1D:
                   compression = Image.CCITTG3_1D;
                   break;
              case TIFFImage.COMP_FAX_G3_2D:
                   compression = Image.CCITTG3_1D;
                   if (dir.isTagPresent(TIFFImageDecoder.TIFF_T4_OPTIONS)) {
                       if (((int)dir.getFieldAsLong(TIFFImageDecoder.TIFF_T4_OPTIONS) & 1) != 0)  {
                           compression = Image.CCITTG3_2D;
                       }
                   }
                   break;
              case TIFFImage.COMP_FAX_G4_2D:
                   compression = Image.CCITTG4;
                   break;
              default:
                   throw new UnsupportedOperationException("Compression type " + compression + " not supported");
          }
          byte im[] = new byte[(int)size];
          in.seek(offset);
          in.readFully(im);
          // IMAGE FROM RAWDATA ...
          Image img = Image.getInstance((int)w, (int)h, reverse, compression, 0, im);
          img.scaleToFit(usableWidth,usableHeight);
          img.setAbsolutePosition(document.left(), document.bottom());
          cb.addImage(img);
          document.newPage();
      }
      document.close();
      
      result = bout.toByteArray();
  
      bout.close();
  } catch (Exception e) {
   throw new FSMException(new ErrorMessageVB(FSMKeys.SEVERITY_ERROR,FSMKeys.ERROR_GLOBAL_CONVERTER, e.getMessage()));
  }
  
     return result;
 }
}
 
 

Best regards,

Stefan.

 

--
syngenio AG                              
Niederlassung Stuttgart
Badstrasse 9                             
70372 Stuttgart    

Tel: 0711 - 4903 - 495
Fax: 0711 - 4903 - 500
Mobil: 0172 - 8672015
http://www.syngenio.de

-----Ursprüngliche Nachricht-----
Von: Paulo Soares [mailto:[EMAIL PROTECTED]
Gesendet: Dienstag, 28. September 2004 18:40
An: Dr. Stefan Reisner; [EMAIL PROTECTED]
Betreff: RE: [iText-questions] (no subject)

It should work with Acrobat 4 and above. What code are you using to read the tiff?
 
Best Regards,
Paulo Soares


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dr. Stefan Reisner
Sent: Tuesday, September 28, 2004 1:53 PM
To: [EMAIL PROTECTED]
Subject: [iText-questions] (no subject)

Hello,

My client is getting reports from customers who have the commercial Acrobat software (as opposed to the free Acrobat Reader) installed, complaining that they cannot view or print the PDF documents that the application serves using iText 1.02b. The PDF documents consist just of one large TIFF image.

Is anything known about compatibility issues in this respect? In particular, what is the oldest Acrobat version that should be able to process a PDF generated by iText 1.02b, containing a TIFF image?

Best regards,
Stefan.

--
syngenio AG                              
Niederlassung Stuttgart
Badstrasse 9                             
70372 Stuttgart    

Tel: 0711 - 4903 - 495
Fax: 0711 - 4903 - 500
Mobil: 0172 - 8672015
http://www.syngenio.de


Reply via email to