如何连接并打印到HP POS打印机? [英] How do I connect and print to HP POS printer?

查看:95
本文介绍了如何连接并打印到HP POS打印机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生,



我尝试用C#.net编写代码,用于使用OPOSPOSPritner.dll进行Windows窗体POS打印连接,但是因为错误而失败了类型转换错误的com对象接口。我需要使用以前的类和dll文件进行维护。请帮我指出继续为此工作。我没有找到太多的POS打印示例代码。在此先感谢。



我尝试过:



使用System;

使用System.Data;

使用System.Drawing;

使用POS.Devices;



使用System.Text;

使用System.Windows.Forms;





命名空间WindowsFormsApplication3

{

公共部分类Form1:表格

{

private OPOSPOSPrinter printer = null;



public Form1()

{

InitializeComponent();

}



private void btnPrint_Click(object sender,EventArgs e)

{



printer = new OPOSPOSPrinterClass();

printer.Open(ReceiptPrinter1);

printer.ClaimDevice(1000);

printer.DeviceEnabled = true;

printer.PrintNormal(2,\ x1B | cA \ x1B | 2COPOS POSPrinter \ x1B | 1C \ nn,Microsoft.NET \ n \\ n);

printer.Close( );

}

}

}

解决方案

嘿,

您的问题确实是针对特定设备指定的,但我认为以下步骤可以帮助您克服此问题。但是,以下步骤不是解决方案,但它们是找到可能解决方案的正确方法。



首先,确保您遵循了正确的实施方案设备供应商的目的。

其次,尝试阅读此链接并了解OPOS的概念因为它有一些很好的提示。

第三,使用faile和try方法以及F7或F11并确保一切都以正确的方式执行。例如:



 printer =  new  OPOSPOSPrinterClass();  //  确保您不需要初始化任何内容并检查重载的构造函数 
printer。打开( ReceiptPrinter1); // 执行此行后检查您的打印机类,并确保实例化的类(打印机)没有错误
printer.ClaimDevice( 1000 ); // 是否应该汇集您的设备
printer.DeviceEnabled = ;
printer.PrintNormal( 2 \\ \\ x1B | cA \ x1B | 2COPOS POSPrinter \ x1B | 1C \ nn Microsoft.NET \ n \ n); // 确保此行似乎很棘手
printer.Close();





最后不要忘记将try {} catch {}正文添加到您的代码中。

顺便说一句,如果以上步骤都没有帮助您解决问题吗?毫不犹豫地发送电子邮件至

 Curtiss Monroe 
crmonroe@monroecs.com



祝你好运

AH


Dear Sir,

I tried to write code with C#.net for windows form POS-printing connection using OPOSPOSPritner.dll but it is failed with the error with of type casting wrong for com object to interface. I need to use the previous class and dll files for maintenance. Please help me to point out to continue working for that. I haven't found much for that POS printing sample code. Thanks in advance.

What I have tried:

using System;
using System.Data;
using System.Drawing;
using POS.Devices;

using System.Text;
using System.Windows.Forms;


namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
private OPOSPOSPrinter printer = null;

public Form1()
{
InitializeComponent();
}

private void btnPrint_Click(object sender, EventArgs e)
{

printer = new OPOSPOSPrinterClass();
printer.Open("ReceiptPrinter1");
printer.ClaimDevice(1000);
printer.DeviceEnabled = true;
printer.PrintNormal(2, "\x1B|cA\x1B|2COPOS POSPrinter\x1B|1C\nvia Microsoft.NET\n\n");
printer.Close();
}
}
}

解决方案

Hey,
Your question is really specified for a specific device but I think the following steps can help you to overcome this problem. However, following steps are not a solution but they are a right method to finding out possibly solutions.

First of all, make sure that you have followed the right implementation which purposed by device vendor.
Second, try to read this link and understand the concept of OPOS for .Net as it has some good hints.
Third, use faile and try method and F7 or F11 and make sure everything is executing in a right way. For example:

printer = new OPOSPOSPrinterClass(); //Make sure you don`t need to initialize anything and check overloaded constructors
printer.Open("ReceiptPrinter1"); // Check your printer class after executing this line and make sure there is no fault on the instantiated class (printer)
printer.ClaimDevice(1000); //Is it enought to pool your device
printer.DeviceEnabled = true;
printer.PrintNormal(2, "\x1B|cA\x1B|2COPOS POSPrinter\x1B|1C\nvia Microsoft.NET\n\n");//Make sure about this line seems to be tricky
printer.Close();



At the end do not forget to add try{} catch{} body to your code.
Btw, if none of the above steps did not help you to solve your problem do not hesitate to drop and email to

Curtiss Monroe
crmonroe@monroecs.com

.
Good luck
A.H.


这篇关于如何连接并打印到HP POS打印机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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