Question

I am using Fedex ship web service to create a shipment. I am using a thermal printer to print the label (Java).

First I wanted to know what should be STOCKTYPE for printing to ZLPII printer, second question follows below.

When printing to the printer and empty label comes out but nothing print, when I use to print to PDF it works very well.

This is my Java code

PrintService pss[] = PrintServiceLookup.lookupPrintServices(DocFlavor.INPUT_STREAM.AUTOSENSE, null);
if (pss.length == 0)
    System.out.println("FedExSmartPostServiceImpl::saveLabelToFile No printer services available.");

PrintService ps = null;
for (PrintService ps1 : pss) {
    if (ps1.getName().indexOf("Zebra") >= 0) {
        ps = ps1;
        break;
    }
}
System.out.println("FedExSmartPostServiceImpl::saveLabelToFile Printing to " + ps);
DocPrintJob job = ps.createPrintJob();
Doc doc = new SimpleDoc(fis, DocFlavor.INPUT_STREAM.AUTOSENSE, null);
job.print(doc, null);
fis.close();

Thanks for the help in advance.

Was it helpful?

Solution

I could able to print the label with almost same code as above, with slight change of changing the SimpleDoc as below rather using the FileInputStream.

Doc doc = new SimpleDoc(byteArr, DocFlavor.BYTE_ARRAY.AUTOSENSE, null);

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top