POS应用开发-收据打印 [英] POS Application Development - Receipt Printing

查看:30
本文介绍了POS应用开发-收据打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在为餐厅/酒吧构建 POS 应用程序.
设计部分已经完成,在过去的一个月里我一直在编写代码.
一切正常,除了现在我需要打印.我必须使用连接到运行该软件的计算机的收据打印机进行打印,然后我将尝试使用厨房打印机等远程打印机进行打印.

I've been building a POS application for a restaurant/bar.
The design part is done and for the past month I've been coding it.
Everything works fine except now I need to print. I have to print to a receipt printer connected to the computer running the software and later I'll try to print in a remote printer like a kitchen one.

我曾在此问题上寻求帮助,结果发现在这些类型的打印机中打印的标准是使用 POS for .NET.问题是,这现在有点过时了,或者至少自几年以来它没有任何更新.关于如何使用这个库,有很多问题被问到,大多数答案都不太容易理解.因此,如果有人可以在收据打印机上提供像简单短语(Hello World")这样的打印步骤的逐步帮助,我将不胜感激.
我正在使用在 64 位 Windows 7 上运行的 Visual Studio 2012我正在用 C# 编写 WPF.

I've searched for help in the matter only to find that the standard for printing in these types of printers is using POS for .NET. The thing is, this is now a bit outdated or at least it hasn't had any updates since a couple of years. There's a lot of questions being asked on how to use this library and most of the answers aren't quite easy to follow. So if anybody could give a step by step help on printing like a simple phrase ("Hello World") on a receipt printer i would be very grateful.
I'm using visual studio 2012 running on a 64 bit windows 7 and i'm coding WPF in c#.

推荐答案

POS for .NET 可能是要走的路.

POS for .NET is probably the way to go.

大多数收据打印机制造商都会提供 OPOS 服务对象.

Most receipt printer manufacturers will provide an OPOS service object.

以及正如这篇 MSDN 文章所述, POS for .NET 兼容 OPOS v1.8 服务对象.

And as this MSDN article states, POS for .NET is compatible with OPOS v1.8 service objects.

OPOS/UPOS(.NET 的 POS 所基于的)恕我直言是一个设计糟糕的 API(由设备制造商而不是应用程序开发人员设计),但它是您今天拥有的最好的.

OPOS / UPOS (on which POS for .NET is based) is IMHO a poorly-designed API (designed by device manufacturers rather than application developers), but it's the best you have today.

我没有任何具体示例,但基础知识与 OPOS 相同 - 您需要打开、声明、启用设备,然后您可以调用其方法(例如打印).您可以尝试查看 OPOS 示例,例如 这个 PosPrinter1 示例,它可能非常相似到 .NET 的 POS.

I don't have any specific samples but the basics are the same as OPOS - you need to Open, Claim, Enable a device, then you can call its methods (such as Print). You might try looking at an OPOS sample, for example this PosPrinter1 sample, which will probably be very similar to POS for .NET.

此博客 有一些关于为 .NET 设置 POS 的信息,可能会有帮助.

This blog has some information about setting up POS for .NET that might be helpful.

更新

这是用于 OPOS 打印机的 VB Hello World.您首先需要创建打印机并将其添加到注册表中,并使用所需的逻辑设备名称 = LDN.我相信爱普生 ADK 包含一个实用程序,可以在注册表中添加打印机.此实用程序还可以对打印机执行健康检查以检查其安装是否正确.完成此操作后,将下面的代码调整为适用于 .NET 的 POS 应该很容易

Here's a VB Hello World for an OPOS printer. You first need to create a printer and add it to the registry with the required Logical Device Name = LDN. I believe the Epson ADK includes a utility to add a printer in the registry. This utility can also perform a health check on the printer to check it is installed correctly. Once you've done this, it should be easy enough to adapt the code below to POS for .NET

OPOSPOSPrinter.Open "MyPrinter"    ' LDN of your printer   
OPOSPOSPrinter.Claim 500           ' Timeout   
OPOSPOSPrinter.DeviceEnabled = True  

'- Print   
OPOSPOSPrinter.PrintNormal 2, "Hello world"  

'- Close the printer   
If OPOSPOSPrinter.Claimed then   
   OPOSPOSPrinter.Release   
End If  
OPOSPOSPrinter.Close  

这篇关于POS应用开发-收据打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆