我可以在不发送原始文本的情况下在 Zebra GX430t 打印机上打印标签吗

Can I print labels on a Zebra GX430t printer without sending raw text

我用 C# 创建了一个应用程序,它创建标签格式并将它们以 ZPL II 格式发送到 Zebra 打印机。为了使打印机正常运行,我需要使用 pinvoke 调用向 winspool.Drv dll 发送打印机原始文本。在我们使用 RDP 远程连接到我们的一台服务器的一位客户上试用它之前,它一直运行良好。事实证明,通过 RDP 的打印机重定向使用 EasyPrint,而 EasyPrint 会阻塞 RawPrinterHelper 调用并阻止任何打印。我的网络人员声称我们不能在不破坏服务器上所有其他重定向打印机的情况下关闭它。

我注意到打印机的默认驱动程序似乎与 'normal' 打印机一样。我正在尝试找到一种使用此默认驱动程序 (ZDesigner GX430t) 将标签打印到此打印机的方法。我似乎找不到任何有关执行此操作的文档。我将尝试使用标准 C# 命令以与任何其他打印机相同的方式绘制到打印机,但我想确保我没有遗漏任何内容。有没有其他人做过这样的事?

好的,感谢 ScanTexas 的人员,我想我找到了解决方案。 打印机驱动程序有一个允许 'Pass Through' 个字符的设置。您可以将这些包含在您的 PrintDocument 中,只需在您的标签前加上起始字符“${”并在末尾附加结束字符“}$”。以下是说明: pass thru instructions

这是我的测试代码(winform形式):

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;

namespace ZebraPrint
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Button1_Click(object sender, System.EventArgs e)
        {
            using (PrintDocument doc = new PrintDocument())
            {
                doc.PrintPage += new PrintPageEventHandler(document_PrintPage);

                using (PrintDialog pd = new PrintDialog())
                {
                    pd.PrinterSettings = new PrinterSettings();
                    pd.Document = doc;
                    if (pd.ShowDialog(this) == DialogResult.OK)
                    {
                        pd.Document.Print();
                    }
                }
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void document_PrintPage(object sender, PrintPageEventArgs e)
        {
            Font printFont = new Font("Consolas", 6);
            SizeF size = e.Graphics.MeasureString("WWWWWW", printFont);
            float printTextHeight = size.Height;
            float top = 0;

            e.Graphics.DrawString(@"${^XA", printFont, System.Drawing.Brushes.Black, 10, top += printTextHeight);
            e.Graphics.DrawString(@"^MD0", printFont, System.Drawing.Brushes.Black, 10, top += printTextHeight);
            e.Graphics.DrawString(@"^MMT", printFont, System.Drawing.Brushes.Black, 10, top += printTextHeight);
            e.Graphics.DrawString(@"^MNY", printFont, System.Drawing.Brushes.Black, 10, top += printTextHeight);
            e.Graphics.DrawString(@"^LL600", printFont, System.Drawing.Brushes.Black, 10, top += printTextHeight);
            e.Graphics.DrawString(@"^LH95,75", printFont, System.Drawing.Brushes.Black, 10, top += printTextHeight);
            e.Graphics.DrawString(@"^FO0,0^AA,54^FD  Palmdale Oil Company, Inc.^FS", printFont, System.Drawing.Brushes.Black, 10, top += printTextHeight);
            e.Graphics.DrawString(@"^FO0,100^AC,36^FDCustomer: AVERITT EXPRESS^FS", printFont, System.Drawing.Brushes.Black, 10, top += printTextHeight);
            e.Graphics.DrawString(@"^FO0,136^AC,36^FD Vehicle: 66030^FS", printFont, System.Drawing.Brushes.Black, 10, top += printTextHeight);
            e.Graphics.DrawString(@"^FO0,172^AC,36^FD    Desc: REEFER^FS", printFont, System.Drawing.Brushes.Black, 10, top += printTextHeight);
            e.Graphics.DrawString(@"^FO0,208^AC,36^FD     TAG: ^FS", printFont, System.Drawing.Brushes.Black, 10, top += printTextHeight);
            e.Graphics.DrawString(@"^FO0,275", printFont, System.Drawing.Brushes.Black, 10, top += printTextHeight);
            e.Graphics.DrawString(@"^BY5", printFont, System.Drawing.Brushes.Black, 10, top += printTextHeight);
            e.Graphics.DrawString(@"^BC,150,N,N,N,N^FD4770013-66030", printFont, System.Drawing.Brushes.Black, 10, top += printTextHeight);
            e.Graphics.DrawString(@"^FS", printFont, System.Drawing.Brushes.Black, 10, top += printTextHeight);
            e.Graphics.DrawString(@"^FO0,430^AC,36^FD4770013-66030^FS", printFont, System.Drawing.Brushes.Black, 10, top += printTextHeight);
            e.Graphics.DrawString(@"^XZ}$", printFont, System.Drawing.Brushes.Black, 10, top += printTextHeight);
        }
    }
}