如何使用PAX A920打印收据?

huangapple go评论67阅读模式
英文:

How to print receipt with PAX a 920?

问题

我有一台运行Android系统的Pax A920设备。
那么在Java中如何使用打印服务呢?

英文:

I have Pax A920 which runs with android .
So how to using printing service in java?

答案1

得分: 1

我建议您使用Neptune API。您可以在Google上搜索"Pax 920 Neptune API演示",第一个显示的链接(https://docs.hips.com/docs/pax-a920)包含一个展示所有基本功能(包括打印机)的演示,您可以在您的设备上运行它:

在应用程序中,您首先需要一个用于检索IDAL的函数:

public static IDAL getDal() {
    if(dal == null){ // dal是应用程序的一个私有静态IDAL变量
        try {
            dal = NeptuneLiteUser.getInstance().getDal(context);
        } catch (Exception e) {}
    }
    return dal;
}

然后在您的活动中,您只需要执行以下操作:

try {
    IPrinter printer = MyApp.getDal().getPrinter();
    printer.init();
    printer.printStr("您的文本", null);
    printer.start();
} catch (PrinterDevException e) {
    e.printStackTrace();
}
英文:

I suggest you to use the Neptune api. you can google pax 920 neptune api demo and the fist link that shows up (https://docs.hips.com/docs/pax-a920) contains a demo that shows all the basic functions (including the printer) and you can run it on your device:

In the Application you first need a function to retrieve the IDAL:

public static IDAL getDal() {
    if(dal == null){ //dal is a private static IDAL variable of the application
        try {
            dal = NeptuneLiteUser.getInstance().getDal(context);
        } catch (Exception e) {}
    }
    return dal;
}

then in your activity you can just do the following:

try {
    IPrinter printer=   MyApp.getDal().getPrinter();
    printer.init();
    printer.printStr("Your text",null);
    printer.start();
} catch (PrinterDevException e) {
    e.printStackTrace();
}

huangapple
  • 本文由 发表于 2020年9月6日 06:35:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/63759114.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定