• 【求助】关于.NET(C#)调用斑马打印机(ZDesigner GK888t (EPL))换页时退纸的问题


    有解决过类似问题的大神请留步,救救我吧。
    -------分割-------
    最近在做一个快递标签打印系统,使用.NET(C#)调用斑马打印机【ZDesigner GK888t (EPL)】进行打印,程序实现的是连续打印,但实际打印机却是打一张,停一下,退一点纸,然后下一张,再停一下,。。。依此类推。
    因为是大批量的标签,所以这个间隔不能忍受,尝试了各种打印机属性和选项的设置都没有用。
    百度看到有人说换成海鸥的驱动,测试后果然不再中间停顿,但业务方不是很接受这个方案(机器较多,换驱动的工作量也蛮大的),没办法只能找代码的问题,测试发现即使把打印逻辑精简到最简也一样会停顿,以下是打印两页最精简的测试代码,请帮我看看有什么不妥:
    方案一:

    using System.Drawing.Printing;
    using System.IO;
    using System.Windows.Forms;
    
    namespace PrintServer
    {
    internal static class Program
    {
    /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    private static void Main(string[] args)
    {
    for (int i = 0; i < 2; i++)
    {
    Test();
    }
    }
    
    private static void Test()
    {
    var printDocument = new PrintDocument();
    printDocument.PrintPage += new PrintPageEventHandler(printDocument_PrintPage);
    printDocument.PrinterSettings.PrinterName = "ZDesigner GK888t (EPL)";
    printDocument.Print();
    }
    
    private static void printDocument_PrintPage(object sender, PrintPageEventArgs e)
    {
    e.Graphics.DrawLine(Pens.Black, 100, 100, 200, 200);
    }
    }
    }


    方案二:

    using System.Drawing.Printing;
    using System.IO;
    using System.Windows.Forms;
    
    namespace PrintServer
    {
    internal static class Program
    {
    /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    private static void Main(string[] args)
    {
    Test();
    }
    
    private static void Test()
    {
    var printDocument = new PrintDocument();
    printDocument.PrintPage += new PrintPageEventHandler(printDocument_PrintPage);
    printDocument.PrinterSettings.PrinterName = "ZDesigner GK888t (EPL)";
    printDocument.Print();
    }
    
    private static int _printedCount = 0;
    private static void printDocument_PrintPage(object sender, PrintPageEventArgs e)
    {
    e.Graphics.DrawLine(Pens.Black, 100, 100, 200, 200);
    _printedCount++;
    e.HasMorePages = _printedCount < 2;
    }
    }
    }

    使用了以上两种方案进行打印测试,均会在两页之间有个明显的暂停并且回纸。

  • 相关阅读:
    招聘里常见的沟通能力到底是什么
    C++服务器linux开发环境管理
    网络游戏通信协议双向迭代加密
    win10控制台程序printf死锁问题
    手游系统逻辑档案之通信协议
    STL插入删除和查询测试
    MATLAB复制图片时边框大的问题
    2019网易笔试题C++--丰收
    暴力求解最长公共子串
    顺时针打印矩阵
  • 原文地址:https://www.cnblogs.com/zhhb/p/6486403.html
Copyright © 2020-2023  润新知