zoukankan      html  css  js  c++  java
  • 【求助】关于.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;
    }
    }
    }

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

  • 相关阅读:
    Redis学习之一--基础知识
    工作流学习之--TPFlow数据库分析
    什么是域名?什么网站名?什么是URL
    SASS的升级版--SCSS 基本介绍+Sass使用详解
    vue调试工具vue-devtools的安装(win10系统,最新2020年6月的解决方案)
    如何运行vue项目
    用WebStorm搭建vue项目
    Terminal怎么停止VUE项目
    VUE 在一个组件中引用另外一个组件的两种方式
    Vue.js——60分钟快速入门 开发· webpack 中文文档
  • 原文地址:https://www.cnblogs.com/zhhb/p/6486403.html
Copyright © 2011-2022 走看看