英文:
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();
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论