简体   繁体   English

Fedex使用Java将标签打印运送到热敏打印机

[英]Fedex ship label print to Thermal printer using Java

I am using Fedex ship web service to create a shipment. 我正在使用Fedex船舶网络服务来创建货运。 I am using a thermal printer to print the label (Java). 我正在使用热敏打印机来打印标签(Java)。

First I wanted to know what should be STOCKTYPE for printing to ZLPII printer, second question follows below. 首先,我想知道什么是STOCKTYPE才能打印到ZLPII打印机,下面是第二个问题。

When printing to the printer and empty label comes out but nothing print, when I use to print to PDF it works very well. 当使用打印机进行打印并且出现空标签但无法打印时,当我使用PDF进行打印时效果很好。

This is my Java code 这是我的Java代码

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. 我在这里先向您的帮助表示感谢。

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. 我可以使用与上面几乎相同的代码来打印标签,只需稍稍更改以下内容即可更改SimpleDoc,而不是使用FileInputStream。

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

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM