• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Print Service API!!!(File not printed)

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Folks,
I am using java print service API, for printing generated PDF files, thorugh system's default printer (WinXP OS-system). Now, every time I run the app.,the printer only prints "PDF file not printed.128 MB of memory is reqd. to enable direct PDF printing". If any of you have come across this problem, and has any solution, please pass it onto me.

here is my code snippet
-------------------------------------------
/** "out" refers to ByteOutputStreamArray object,
* which is popolated during PDF generation through XSLT
*/

DocFlavor psFlavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
System.out.println("Step 6 is done");
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(new Copies(2));
System.out.println("Step 7 is done");
PrintService pservice = PrintServiceLookup.lookupDefaultPrintService();
System.out.println("Step 8 is done");
if (pservice != null) {
System.out.println("Printer name=>"+pservice.getName());
DocPrintJob pj = pservice.createPrintJob();
System.out.println("Step 9 is done");
try {
if(out != null){
Doc doc = new SimpleDoc(out.toByteArray(), psFlavor, null);
System.out.println("Step 10 is done");
pj.print(doc, null);
System.out.println("Step 11 is done=>document is sent to Printer");
}
else{
System.out.println("The ByteArrayOutputStream is NULL");
}
}
catch (PrintException e) {
System.out.println("Step 12A is reached");
e.printStackTrace();
}
catch (Exception ex){
System.out.println("Step 12B is reached");
ex.printStackTrace();
}
}
else{
System.out.println("No printer service is found!!!");
}
--------------------------------------------------------
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic