Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/258.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.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# 双面打印使用纸张的反面_C#_.net_Printing - Fatal编程技术网

C# 双面打印使用纸张的反面

C# 双面打印使用纸张的反面,c#,.net,printing,C#,.net,Printing,以下代码用于打印两页。在单工模式下打印时,将打印纸张的正确一面。在双面打印模式下打印时,纸张以正确的方向从打印机中出来,但在打印过程中纸张被翻转,并且前/后页打印在纸张的错误侧面,即使纸张已正确装入打印机。在特殊库存上打印作业时,这是一个重要问题。此问题已在多个HP双面打印机型号上测试和复制。打印机端的行为似乎不一致,但唯一的修复方法是在代码中反转页面打印顺序 这是常见的打印机问题吗 有没有更好的方法在代码中解决这个问题 private int _pageCnt = 0; private vo

以下代码用于打印两页。在单工模式下打印时,将打印纸张的正确一面。在双面打印模式下打印时,纸张以正确的方向从打印机中出来,但在打印过程中纸张被翻转,并且前/后页打印在纸张的错误侧面,即使纸张已正确装入打印机。在特殊库存上打印作业时,这是一个重要问题。此问题已在多个HP双面打印机型号上测试和复制。打印机端的行为似乎不一致,但唯一的修复方法是在代码中反转页面打印顺序

  • 这是常见的打印机问题吗
  • 有没有更好的方法在代码中解决这个问题

    private int _pageCnt = 0;
    
    private void PrintTest(string printerName, bool duplex)
    {
      System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();
    
      pDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(pDoc_PrintPage);
    
      _pageCnt = 1;
    
      pDoc.PrinterSettings.PrinterName = printerName;
      pDoc.PrinterSettings.Duplex = (duplex) ? System.Drawing.Printing.Duplex.Vertical : System.Drawing.Printing.Duplex.Simplex;
      pDoc.Print();
    }
    
    private void pDoc_PrintPage(Object sender, System.Drawing.Printing.PrintPageEventArgs e)
    {
      e.Graphics.DrawString(_pageCnt.ToString(), new System.Drawing.Font("Arial", 40), Brushes.Black, new System.Drawing.PointF(50, 50));
      _pageCnt += 1;
    
      e.HasMorePages = (_pageCnt <= 2);  
    }
    
    private int\u pageCnt=0;
    私有void PrintTest(字符串printerName、bool duplex)
    {
    System.Drawing.Printing.PrintDocument pDoc=新的System.Drawing.Printing.PrintDocument();
    pDoc.PrintPage+=新系统.Drawing.Printing.PrintPageEventHandler(pDoc_PrintPage);
    _pageCnt=1;
    pDoc.PrinterSettings.PrinterName=PrinterName;
    pDoc.PrinterSettings.Duplex=(Duplex)?System.Drawing.Printing.Duplex.Vertical:System.Drawing.Printing.Duplex.Simplex;
    pDoc.Print();
    }
    私有void pDoc_打印页(对象发送方,System.Drawing.Printing.PrintPageEventArgs e)
    {
    e、 Graphics.DrawString(_pageCnt.ToString(),new System.Drawing.Font(“Arial”,40),brush.Black,new System.Drawing.PointF(50,50));
    _pageCnt+=1;
    
    e、 HasMorePages=(_pageCnt这是一些型号的HP和理光打印机的已知问题。 单面打印时,从纸张的一侧开始打印。双面打印时,从输入纸张的另一侧开始打印。 这是一个问题,如果你使用预打印纸,如信笺或支票,你有两个单面和双面页面

    理光和HP打印机中都有处理此问题的打印机设置。请在“信纸处理设置”下查找


    话虽如此,我们遇到了支票库存的问题。我们通过将每一页打印为双面打印来解决这个问题,即使页面背面没有任何内容。我们嵌入了一些HP PCL命令,以便始终为我们提供第二页,即使它是空的。

    这不是一个选择,以另一种方式加载纸张库存吗?@RowlandShaw挑战在于使用这种特殊库存的一些打印作业是单工的,而一些是双面的。