Works ok with a Xerox 5675 and an Epson AL-C3900. Maybe you have a
printer driver problem.

Paulo

On Fri, Jul 13, 2012 at 1:09 PM, Chaudhary Himanshu (KFSC 241)
<himanshu.chaudh...@credit-suisse.com> wrote:
> Hi There
>
>
>
> I used i-Text5.0.2 to generate PDFs from scanned TIFFs but when we are
> printing on a printer (Xerox Phaser 3250), which is connected by USB took
> 7-8 minutes.
>
> But when we tried to print PDF generated by different tool it was only 90 to
> 120 seconds. Below is the java code we used to generate the PDFs.
>
>
>
> Also attaching the TIFFS and the generated pdfs.
>
>
>
> Your help is highly appreciated.
>
>
>
> Thanks
>
> Himanshu
>
>
>
> import java.io.ByteArrayOutputStream;
>
>
>
> import com.csg.cs.core.base.logging.Logger;
>
> import com.csg.cs.formsec.base.exception.FormsecException;
>
> import com.csg.cs.formsec.base.logging.FSLoggerHelper;
>
> import com.csg.cs.formsec.base.logging.ifh.InstructionForHelpAction;
>
> import com.csg.cs.formsec.base.logging.ifh.InstructionForHelpLogger;
>
> import com.csg.cs.formsec.dms.DmsConstants;
>
> import com.itextpdf.text.Document;
>
> import com.itextpdf.text.Image;
>
> import com.itextpdf.text.PageSize;
>
> import com.itextpdf.text.pdf.PdfWriter;
>
> import com.itextpdf.text.pdf.RandomAccessFileOrArray;
>
> import com.itextpdf.text.pdf.codec.TiffImage;
>
>
>
> /**
>
> * This class generates a PDF with the passed TIFF as content
>
> *
>
>  * @author F223985
>
> *
>
>  */
>
> public class Image2Pdf implements DmsConstants {
>
>
>
>   private static Logger logger = FSLoggerHelper.getLogger(Image2Pdf.class);
>
>   private static String[] empty = {};
>
>
>
>   public static byte[] generatePdf(byte[] input) throws FormsecException {
>
>     return generatePdf(new byte[][] {input});
>
>   }
>
>
>
>   public static byte[] generatePdf(byte[][] inputs) throws FormsecException
> {
>
>
>
>     // Check input
>
>
>
>     // Create Document
>
>     Document document = new Document(PageSize.A4);
>
>     float margin = 0f; // 12pt
>
>     document.setMargins(margin, margin, margin, margin);
>
>     ByteArrayOutputStream os = new ByteArrayOutputStream();
>
>     try {
>
>       PdfWriter.getInstance(document, os);
>
>       document.open();
>
>       document.setMargins(40f, 40f, 40f, 40f);
>
>
>
>       boolean firstPage = true;
>
>       for (int i = 0; i < inputs.length; i++) {
>
>         // we have to place every image on a separate
>
>         // page
>
>         if (firstPage) {
>
>           firstPage = false;
>
>         } else {
>
>         }
>
>         byte[] input = inputs[i];
>
>         RandomAccessFileOrArray ra = new RandomAccessFileOrArray(input);
>
>         if (isTiff(input) && TiffImage.getNumberOfPages(ra) > 1) {
>
>           // We handle a multipage tiff
>
>           int numPages = TiffImage.getNumberOfPages(ra);
>
>           for (int page = 1; page <= numPages; page++) {
>
>             Image img = TiffImage.getTiffImage(ra, page);
>
>
>
>             if (img.getHeight() > img.getWidth()) {
>
>               document.setPageSize(PageSize.A4);
>
>               img.scaleAbsolute(PageSize.A4.getWidth() - 80f,
> PageSize.A4.getHeight() - 80f);
>
>             } else {
>
>               img.scaleAbsolute(PageSize.A4.getHeight() - 80f,
> PageSize.A4.getWidth() - 80f);
>
>               // Rotate
>
>               // img.setRotationDegrees(90.0f);
>
>               document.setPageSize(PageSize.A4.rotate());
>
>             }
>
>
>
>             document.newPage();
>
>             document.add(img);
>
>           }
>
>
>
>         } else {
>
>           // We handle all other kinds of images
>
>           Image img = Image.getInstance(input);
>
>           if (img.getHeight() > img.getWidth()) {
>
>             document.setPageSize(PageSize.A4);
>
>             img.scaleAbsolute(PageSize.A4.getWidth() - 80f,
> PageSize.A4.getHeight() - 80f);
>
>           } else {
>
>             img.scaleAbsolute(PageSize.A4.getHeight() - 80f,
> PageSize.A4.getWidth() - 80f);
>
>             // Rotate
>
>             // img.setRotationDegrees(90.0f);
>
>             document.setPageSize(PageSize.A4.rotate());
>
>           }
>
>
>
>           document.newPage();
>
>           document.add(img);
>
>         }
>
>       }
>
>     } catch (Exception ex) {
>
>       logger.error("Error generating PDF", ex);
>
>       InstructionForHelpLogger.error(Image2Pdf.class,
> InstructionForHelpAction.CENTERA_IMG2PDF_CONVERSION_ERROR,
>
>           "Error generating PDF", ex);
>
>       throw new FormsecException(MSG_ERR_IMG2PDF_ERROR, empty, ex);
>
>     } finally {
>
>       document.close();
>
>     }
>
>     return os.toByteArray();
>
>   }
>
>
>
>   public static boolean isValidImageFormat(byte[] input) throws
> FormsecException {
>
>     try {
>
>       Image img = Image.getInstance(input);
>
>       return isValidImageFormat(img);
>
>
>
>     } catch (Exception e) {
>
>       logger.error("Error converting data to Image.", e);
>
>       throw new FormsecException(MSG_ERR_TIFF2PDF_INVALID_DATA, empty);
>
>     }
>
>   }
>
>
>
>   public static boolean isValidImageFormat(Image img) throws
> FormsecException {
>
>     return isTiff(img) || isJpeg(img);
>
>   }
>
>
>
>   public static boolean isTiff(byte[] input) throws FormsecException {
>
>     try {
>
>       Image img = Image.getInstance(input);
>
>       return isTiff(img);
>
>
>
>     } catch (Exception e) {
>
>       logger.error("Error converting data to Image.", e);
>
>       throw new FormsecException(MSG_ERR_TIFF2PDF_INVALID_DATA, empty);
>
>     }
>
>   }
>
>
>
>   public static boolean isTiff(Image img) throws FormsecException {
>
>     return img.getOriginalType() == Image.ORIGINAL_TIFF;
>
>   }
>
>
>
>   public static boolean isJpeg(byte[] input) throws FormsecException {
>
>     try {
>
>       Image img = Image.getInstance(input);
>
>       return isJpeg(img);
>
>
>
>     } catch (Exception e) {
>
>       logger.error("Error converting data to Image.", e);
>
>       throw new FormsecException(MSG_ERR_TIFF2PDF_INVALID_DATA, empty);
>
>     }
>
>   }
>
>
>
>   public static boolean isJpeg(Image img) throws FormsecException {
>
>     return img.getOriginalType() == Image.ORIGINAL_JPEG;
>
>   }
>
> }
>
>
>
> Himanshu Chaudhary
>
> CREDIT SUISSE AG
>
> Information Technology | Cognizant FN, KSXJ 51
>
> Zollstrasse 20/36 | 8070 Zürich | Switzerland
>
> Phone +41-765962322
>
> himanshu.chaudh...@credit-suisse.com | www.credit-suisse.com
>
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> iText(R) is a registered trademark of 1T3XT BVBA.
> Many questions posted to this list can (and will) be answered with a
> reference to the iText book: http://www.itextpdf.com/book/
> Please check the keywords list before you ask for examples:
> http://itextpdf.com/themes/keywords.php

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to