Which SDK should I use for KR403 Zebra Printer

牧云@^-^@ 提交于 2020-01-05 03:28:20

问题


I am writing a .Net WPF application using C# for a Windows 7 64 bit platform. My application needs to communicate with a Zebra KR403 printer connected through USB. My questions may be very basic, but I'm hoping this post will help others who are new to using this printer in .Net.

1. Which SDK should I be using? Is it as simple as adding a .dll to my project and using it? I have tried using the Windows CE SDK, but I get a BadImageFormatException when the ZSDK_API.dll tries to load ZebraUsb.dll. This usually means that the dll was compiled for a different platform.

2. Should I be using the SDK to print or should I be using the normal .Net printing libraries? What are the advantages of the two options? For example, if I use .Net libraries for printing will I still have to use ZBI (the language used to communicate with the printer)?

3. How do I get the status of the printer (out of paper, media not loaded, etc.)? I have found a guide (had to remove link; reputation not high enough to post more than 2 links) which explains how to do it in Windows CE or Mobile, but I cannot find the equivalent for Windows 7 (the normal desktop version).

If someone can help me with these questions I would greatly appreciate it and I will post my final solution (or the core code needed to do the above) here for others to use.

Thank you in advance for any help.

UPDATE:

I found some code that allows me to communicate directly to the printer over USB here: http://danielezanoli.blogspot.com/2010/06/usb-communications-with-zebra-printers.html

I also found a hardware integrators guide for the KR403 printer which explains the result of the ~HQES command here: https://support.zebra.com/cpws/docs/crawl/UG_Kiosk/KR403_UG.pdf#xml=https://km.zebra.com/kb/index?page=answeropen&type=open&searchid=1363543831914&answerid=16777218&iqaction=6&url=https%3A%2F%2Fsupport.zebra.com%2Fcpws%2Fdocs%2Fcrawl%2FUG_Kiosk%2FKR403_UG.pdf&highlightinfo=12583129,8815,8825

I am now able to send the ~HQES command to the printer over USB using the above library or over serial port using the SerialPort class from .Net. I can then interpret the result using the hardware integrators guide above and check the status of the printer. Since this is easy enough to do I'm not going to try and port an SDK at this point.


回答1:


I found some code that allows me to communicate directly to the printer over USB here: http://danielezanoli.blogspot.com/2010/06/usb-communications-with-zebra-printers.html

I also found a hardware integrators guide for the KR403 printer which explains the result of the ~HQES command here: https://support.zebra.com/cpws/docs/crawl/UG_Kiosk/KR403_UG.pdf#xml=https://km.zebra.com/kb/index?page=answeropen&type=open&searchid=1363543831914&answerid=16777218&iqaction=6&url=https%3A%2F%2Fsupport.zebra.com%2Fcpws%2Fdocs%2Fcrawl%2FUG_Kiosk%2FKR403_UG.pdf&highlightinfo=12583129,8815,8825




回答2:


I played with a Zebra printer some years ago. To use the SDK from Zebra, all you should need to do is include a reference to the dll in your project (right-click on references in visual studio and click "add reference", then navigate to the dll). Note: this is assuming they now have .NET assemblies. They didn't back in the day, but it wasn't that hard to add the interop code.

As I remember it, the primary advantage of the SDK (and why I was using it) is that it has some built-in capabilities for label printing including things like barcodes. So you could find a separate library for producing barcodes, but the Zebra SDK lets you just send a string (or number) and have it encode it for you and print the barcode.




回答3:


Zebra doesn't currently offer a .NET SDK for desktop. As you have seen, the Zebra .NET SDK is meant for older Windows CE / Windows Mobile platforms.

Zebra does offer a Java-based SDK. It doesn't claim to support the KR403, but it might be worth 20 minutes of testing to see if you could integrate it with your project: http://www.zebra.com/us/en/products-services/software/link-os/link-os-sdk.html.

As others have mentioned, Zebra's SDKs allow you to check status reliably, as well as take advantage of Zebra printer features (like printer-format storing and recalling. printer-image recalling, non-USB communication, etc.). It should out-perform other generic printing libraries since it was designed for use with Zebra printers.




回答4:


finnaly have found the .dll compatible with c# or VB.net and you can download it from zebra web site : ZSDK API

ZSDK_API.dll ZebraPlatformUtil.dll

i personnaly test these .dll over LAN network zebra printer ZT400,here some code used :

using ZSDK_API.Comm;
using ZSDK_API.ApiException;
using ZSDK_API.Printer;



public void SendZplOverTcp(String theIpAddress)
    {

        try
        {
            // Instantiate connection for ZPL TCP port at given address. 
            ZebraPrinterConnection thePrinterConn = new TcpPrinterConnection(theIpAddress, TcpPrinterConnection.DEFAULT_ZPL_TCP_PORT);

            // Open the connection - physical connection is established here.
            thePrinterConn.Open();

            // This example prints "This is a ZPL test." near the top of the label.
            String zplData = "^XA^FO20,20^A0N,25,25^FDThis is a ZPL test.^FS^XZ";

            // Send the data to printer as a byte array.
            thePrinterConn.Write(Encoding.Default.GetBytes(zplData));

            // Close the connection to release resources.
            thePrinterConn.Close();

        }
        catch (ZebraPrinterConnectionException e)
        {

            // Handle communications error here.
            MessageBox.Show(e.StackTrace);
        }

    }


来源:https://stackoverflow.com/questions/15363941/which-sdk-should-i-use-for-kr403-zebra-printer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!