• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

Subhadip Chatterjee
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • 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");
System.out.println("The ByteArrayOutputStream is NULL");
catch (PrintException e) {
System.out.println("Step 12A is reached");
catch (Exception ex){
System.out.println("Step 12B is reached");
System.out.println("No printer service is found!!!");
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!