Add /QIBM/ProdData/OS400/Java400/ext/ibmjps.jar to your class path.

Then the javax.print.* stuff should work.

Try this:


import javax.print.DocFlavor;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;

public class Printers {

/**
* @param args
*/
public static void main(String[] args) {
PrintService defaultPrintService;
defaultPrintService =
PrintServiceLookup.lookupDefaultPrintService();

System.out.println("DEFAULT PRINTER:");
describe(defaultPrintService);
System.out.println("");

PrintService[] services;
services = PrintServiceLookup.lookupPrintServices(null,
null);

System.out.println("PrintServiceLookup found " +
services.length
+ " printers");

for (int i = 0; i < services.length; i++) {
PrintService service = services[i];
System.out.println("PRINTER " + i);
describe(service);
System.out.println("");
}
}

private static void describe(PrintService printService) {
if (printService == null) {
System.out.println("null argument passed");
return;
}

System.out.println("Name: " + printService.getName());
DocFlavor[] flavors = printService.getSupportedDocFlavors();
for (int i = 0; i < flavors.length; i++) {
DocFlavor flavor = flavors[i];
System.out.println("F " + flavor);
}

Class[] categories =
printService.getSupportedAttributeCategories();
for (int i = 0; i < categories.length; i++) {
Class class1 = categories[i];
System.out.println("A " + class1);

}

}

}


-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Paul Bailey
Sent: 10. oktober 2011 12:53
To: JAVA400-L@xxxxxxxxxxxx
Subject: Printing from Java


Hi,

I am trying to print a PDF using Java called from RPGLE. I know there are
all sorts of problems with PDF printing but I think I have a potential
solution in using the PDFRenderer package from Sun. The problem I am
currently having is that the java.awt.print.PrinterJob.getPrinterJob()
method is returning a nullpointer exception.

I'm thinking that I am going about this all wrong as AWT is not really
implemented properly on the iSeries. What iSeries print options are
available through java400? Can I send a spooled file to (or even use) an
OUTQ at all? Or is that side of things totally disconnected when using Java?


Regards,
Paul.


------------------------------------------------------------
Important

This email transmission and any files with it are strictly
confidential to the intended recipient and may be legally
privileged. Any views or opinions presented are solely
those of the author and do not necessarily represent those
of BHSF. If you are not the intended recipient, you must
not copy, disclose or distribute its contents in any way.
If you have received this e-mail in error, please notify
the sender and delete the e-mail from your system.

We have taken steps to ensure this e-mail and attachments
are free from any virus but do not accept any
responsibility once this e-mail has been transmitted. You
should scan any attachments for viruses.

No contract may be concluded on behalf of BHSF Limited by
e-mail.

Registered Office:
BHSF Limited
Gamgee House, 2 Darnley Road, Birmingham B16 8TE.

www.bhsf.co.uk

Registered in England number 35500.

BHSF is authorised and regulated by the Financial Services
Authority.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2021 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.