Folks - we're sending a print job from java using the code below.
 
  FileInputStream fin = new FileInputStream(fileLocation);
        Doc doc = new SimpleDoc(fin, DocFlavor.INPUT_STREAM.PDF, null); 

        job.print(doc, pras);

 
It prints the default account user separator job page on the printer - but not 
the content of the PDF as well.
 
There's clearly a trick to send the PDF to the print so it gets interpreted and 
actually printed.  Do we need to interprete it to PS first or something?
 
I assume other people have this working - help please!
 
Thanks, DW
 
========================
 
public static void PrintPDFPages(Document document,String fileLocation) {
   try {
        PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); 
        pras.add(new Copies(2)); 

        PrintService pss[] = 
PrintServiceLookup.lookupPrintServices(DocFlavor.INPUT_STREAM.PDF, pras);

        if (pss.length == 0)
          throw new RuntimeException("No printer services available.");

        PrintService ps = pss[0];
        System.out.println("Printer Name [0]"+pss[0].getName().toString());
        System.out.println("Printer Name [1]"+pss[0].getName().toString());
        System.out.println("Printer Name [2]"+pss[0].getName().toString());
        PrintService ps1 = PrintServiceLookup.lookupDefaultPrintService();
        System.out.println("Default printer: "+ps1.getName()); 
        
        System.out.println("Printing to " + ps);

        DocPrintJob job = ps1.createPrintJob();

        FileInputStream fin = new FileInputStream(fileLocation);
        Doc doc = new SimpleDoc(fin, DocFlavor.INPUT_STREAM.PDF, null);

        job.print(doc, pras);

        fin.close();
      } catch (IOException ie) {
        ie.printStackTrace();
      } catch (PrintException pe) {
        pe.printStackTrace();
      }
 }
}

 

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to