Print RTF throws NullPointerException using Java at ISeries

Hello,

We have a requirement to print RTF documents from ISeries by sending them to Printer Queues
Aspose was recommended by a co worker. I tried on Windows, and it worked file. But not on Iseries.
The following code works file in Windows, but not on Iseries
Document doc = new Document(path);
doc.print(printer);
Path refers to path on Iseries and the printer refers to the printer output queue.

We would use Aspose of a lot of things in our environment if we could send RTFs and World files to the printer output queue.

However, sending the RTF to the printer queue prints out the RTF encoded text.
Printing using aspose: 2367073A.rtf
java.lang.NullPointerException
at com.aspose.words.internal.zzZWR.zzZ(Unknown Source)
at com.aspose.words.internal.zzZWS.zzZ(Unknown Source)
at com.aspose.words.AsposeWordsPrintDocument.print(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.zzX(Unknown Source)
at com.aspose.words.Document.print(Unknown Source)
at com.berryglobal.laddawn.DocumentPrint.printDocumentWithAspose(DocumentPrint.java:90)

Has anyone been able successfully send documents to the printer on ISeries.
Thanks

@samadatoro

Please make sure that your printer is connected to your system and you are able to print the document using Java API and manually.

If you still face problem, please ZIP and attach your input RTF document along with your working environment e.g. operating system, Java version etc. We will investigate the issue and provide you more information on it.

Does the print method uses the IBM implementation or the standard java api.
PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null); return an empty array on Iseries.
This code simply return an empty String. Also does Aspose prininting rely on the the AWT ? I’m guessing so. Do you have customers using aspose on Iseries?

private static String printers() {
StringBuilder sb = new StringBuilder();
// list all printers and select the one selected by the user
PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);

	for (int i = 0; i < services.length; i++) {
		PrintService printService = services[i];
		sb.append(printService.getName()).append("\n");

	}

	return sb.toString();
}

@samadatoro

Aspose.Words for Java uses Java APIs to print the document. Aspose.Words can be used in any Java-based applications developed on Windows Unix/Linux and Mac platforms.

Please make sure that the printer is installed at your system.

Have you tried to print the document manually? Please share the complete detail of your working environment e.g. operating system, Java version, etc.

We suggest you please try the code example shared in the following article and let us know how it goes on your side.
Print a Document Programmatically or Using Dialogs

@samadatoro

Further to my previous post, please try the following Java code example to print your Word document and let us how it goes on your end.

public static void printDocument() throws PrintException,
        IOException{

    PrintService ps=PrintServiceLookup.lookupDefaultPrintService();
    DocPrintJob job=ps.createPrintJob();
    job.addPrintJobListener(new PrintJobAdapter() {
        public void printDataTransferCompleted(PrintJobEvent event){
            System.out.println("data transfer complete");
        }
        public void printJobNoMoreEvents(PrintJobEvent event){
            System.out.println("received no more events");
        }
    });
    FileInputStream fis=new FileInputStream(MyDir + "input.docx");
    Doc doc=new SimpleDoc(fis, DocFlavor.INPUT_STREAM.AUTOSENSE, null);
    // Doc doc=new SimpleDoc(fis, DocFlavor.INPUT_STREAM.JPEG, null);
    PrintRequestAttributeSet attrib=new HashPrintRequestAttributeSet();
    attrib.add(new Copies(1));
    job.print(doc, attrib);
}

Thank you very much . Unfortunately the lookupDefaultPrintService() returns null;
I did come across this article IBM Documentation
This explains that the printers need to be configured a certain way to be able to use them with Java Print Service . Currently they are configured as remote OUTQ type printers which might be the reason why Java cannot locate any printer. Anyway around this?
Thanks

@samadatoro

The Java API does not find the printer at your end. Please configure your printer so that it is available to Java.

If you are able to print the document using Java APIs and it does not work for Aspose.Words for Java, please share the requested detail mentioned here. We will investigate the issue and provide you more information on it.