aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Java Print Service API!!!(File not printed) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Java Print Service API!!!(File not printed)" Watch "Java Print Service API!!!(File not printed)" New topic
Author

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

Subhadip Chatterjee
Ranch Hand

Joined: Dec 12, 2006
Posts: 93
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!!!");
}
--------------------------------------------------------


Refreshing life every moment...
 
 
subject: Java Print Service API!!!(File not printed)