This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
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

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");
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!!!");

Refreshing life every moment...
I agree. Here's the link:
subject: Java Print Service API!!!(File not printed)
It's not a secret anymore!