我使用的是b-PAC3.2 SDK,并使用它尝试打印标签并在打印完成后获得一些回调函数。我尝试使用manul中的“处理打印完成事件和回调”示例代码,但它根本无法正常工作。永远不会调用回调函数。有人设法运行它吗?知道有什么问题吗?
此外,还有SetPrintedCallback方法,该方法将object作为参数,但是在任何地方都没有描述如何使用它。也许我应该使用它而不是事件,但是我不知道如何使用它
下面我向您发送我生成的源代码
public static class PrinterWrapper
{
public static void HandlePrinted(int status, object value)
{
LogHelper.Logger.Info("callback");
}
public static void PrintLabel()
{
string templatePath = @"Layouts\LogoLayout.lbx";
bpac.IPrintEvents_PrintedEventHandler delegeate = HandlePrinted;
bpac.DocumentClass doc = new DocumentClass();
doc.Printed += new bpac.IPrintEvents_PrintedEventHandler(HandlePrinted);
if (doc.Open(templatePath) != false)
{
doc.StartPrint("", PrintOptionConstants.bpoDefault);
doc.PrintOut(1, PrintOptionConstants.bpoDefault);
doc.EndPrint();
doc.Close();
}
else
{
LogHelper.Logger.ErrorFormat("Cannot open template file {0}. Error code: {1}", templatePath, doc.ErrorCode);
}
}
}
更新
我没有设法使此活动正常进行。我也没有收到Brother公司的任何回复...我最终使用SNMP协议检查打印机状态。我也决定直接在套接字上将数据发送到打印机,而不使用Brother SDK。似乎这是一种更可靠的打印方式...