Bootstrap

ESC/P打印:程序控制打印机自动进退纸

打印连续纸张的时候,经常会遇到需要自动进退纸的功能,譬如下列场景:
1. 打印完一个小标;(自动进纸)
2. 用户撕断打印出来的小标;
3. (自动退纸,纸张归位) 接着打印下一个小标;

 

下列代码在爱普生LQ 730k打印机上测试通过:

   1: //使用示例
   2: new PrintDirect("PrinterName").PrintESC(1);//打印后进纸
   3: new PrintDirect("PrinterName").PrintESC(0);//打印前退纸

 

源代码:

   1:  
   2:     [StructLayout(LayoutKind.Sequential)]
   3:     public struct DOCINFO
   4:     {
    
   5:         [MarshalAs(UnmanagedType.LPWStr)]
   6:         public string pDocName;
   7:         [MarshalAs(UnmanagedType.LPWStr)]
   8:         public string pOutputFile;
   9:         [MarshalAs(UnmanagedType.LPWStr)]
  10:         public string pDataType;
  11:     }
  12:  
  13:     public class PrintDirect
  14:     {
    
  15:         private string PrintPort { get; set; }
  16:         public PrintDirect(string port)
  17:         {
    
;