Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 我可以在Zebra GX430t打印机上打印标签而不发送原始文本吗_C#_Printing_Rdp_Zebra Printers - Fatal编程技术网

C# 我可以在Zebra GX430t打印机上打印标签而不发送原始文本吗

C# 我可以在Zebra GX430t打印机上打印标签而不发送原始文本吗,c#,printing,rdp,zebra-printers,C#,Printing,Rdp,Zebra Printers,我用C#创建了一个应用程序,它创建标签格式,并以ZPL II格式发送到Zebra打印机。为了使打印机正常工作,我需要使用pinvoke调用将打印机原始文本发送到winspool.Drv dll。在我们的一个客户使用RDP远程连接到我们的一个服务器上之前,它工作得很好。事实证明,打印机通过RDP重定向使用了EasyPrint,EasyPrint阻塞了RawPrinterHelper调用并阻止任何打印。我的网络人员声称,在不中断服务器上所有其他重定向打印机的情况下,我们无法关闭此功能 我注意到打印机

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


我注意到打印机的默认驱动程序似乎与“普通”打印机一样。我正试图找到一种方法,使用此默认驱动程序(ZDesigner GX430t)将标签打印到此打印机。我似乎找不到任何这样做的文档。我将尝试使用标准的C#命令来绘制打印机,就像其他打印机一样,但要确保我没有遗漏任何东西。还有其他人做过类似的事情吗?

好的,多亏了ScanTexas的同事,我想我找到了解决办法。 打印机驱动程序具有允许“传递”字符的设置。您可以在打印文档中包含这些字符,只需在标签前面加上起始字符“${”,并在结尾“}$”处加上结束字符。以下是说明:

这是我的测试代码(winform表单):

使用系统;
使用System.Collections.Generic;
使用系统组件模型;
使用系统数据;
使用系统图;
使用System.Linq;
使用系统文本;
使用System.Windows.Forms;
使用系统、绘图、打印;
名称空间斑马线
{
公共部分类Form1:Form
{
公共表格1()
{
初始化组件();
}
/// 
/// 
/// 
/// 
/// 
无效按钮1\u单击(对象发送者,System.EventArgs e)
{
使用(PrintDocument文档=新的PrintDocument())
{
doc.PrintPage+=新的PrintPageEventHandler(document\u PrintPage);
使用(PrintDialog pd=new PrintDialog())
{
pd.PrinterSettings=新的PrinterSettings();
pd.文件=文件;
if(pd.ShowDialog(this)=DialogResult.OK)
{
pd.Document.Print();
}
}
}
}
/// 
/// 
/// 
/// 
/// 
无效文档\u打印页(对象发送者,PrintPageEventArgs e)
{
Font printFont=新字体(“控制台”,6);
SizeF size=e.Graphics.MeasureString(“ww”,printFont);
浮动打印文本高度=大小。高度;
浮顶=0;
e、 Graphics.DrawString(@“${^XA”,printFont,System.Drawing.brush.Black,10,top+=printTextHeight);
e、 Graphics.DrawString(@“^MD0”,printFont,System.Drawing.Brush.Black,10,top+=printTextHeight);
e、 Graphics.DrawString(@“^MMT”,printFont,System.Drawing.Brush.Black,10,top+=printTextHeight);
e、 Graphics.DrawString(@“^MNY”,printFont,System.Drawing.Brush.Black,10,top+=printTextHeight);
e、 Graphics.DrawString(@“^LL600”,printFont,System.Drawing.Brush.Black,10,top+=printTextHeight);
e、 Graphics.DrawString(@“^LH95,75”,printFont,System.Drawing.Brush.Black,10,top+=printTextHeight);
e、 Graphics.DrawString(“^FO0,0^AA,54^FD Palmdale Oil Company,Inc.^FS”,printFont,System.Drawing.Brusks.Black,10,top+=printTextHeight);
e、 Graphics.DrawString(@“^FO0100^AC,36^FD客户:AVERITT EXPRESS ^FS”,printFont,System.Drawing.Brush.Black,10,top+=printTextHeight);
e、 Graphics.DrawString(“^FO0136^AC,36^FD车辆:66030^FS”,打印字体,System.Drawing.Brush.Black,10,top+=printTextHeight);
e、 Graphics.DrawString(@“^FO0172^AC,36^FD Desc:REEFER^FS”,打印字体,System.Drawing.Brush.Black,10,top+=printTextHeight);
e、 Graphics.DrawString(@“^FO0208^AC,36^FD标记:^FS”,printFont,System.Drawing.Brush.Black,10,top+=printTextHeight);
e、 Graphics.DrawString(@“^FO0275”,printFont,System.Drawing.Brush.Black,10,top+=printTextHeight);
e、 Graphics.DrawString(@“^BY5”,printFont,System.Drawing.Brush.Black,10,top+=printTextHeight);
e、 Graphics.DrawString(@“^BC,150,N,N,N,N^FD4770013-66030”,printFont,System.Drawing.Brush.Black,10,top+=printTextHeight);
e、 Graphics.DrawString(@“^FS”,printFont,System.Drawing.Brush.Black,10,top+=printTextHeight);
e、 Graphics.DrawString(@“^FO0430^AC,36^FD4770013-66030^FS”,printFont,System.Drawing.Brush.Black,10,top+=printTextHeight);
e、 Graphics.DrawString(@“^XZ}$”,printFont,System.Drawing.brush.Black,10,top+=printTextHeight);
}
}
}

经过审查,我的问题不完全是我应该问的。我需要一种不向打印机发送原始文本而打印标签的方法。
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);
        }
    }
}