程序海哥 2017-12-09 08:59 采纳率: 0%
浏览 1203
已结题

c#如何通过终端的rdp协议封装打印到本地打印机。

1、本人c#引用Microsoft RDP Client Control协议,winform托管RemoteApp,已经成功

运行windows server 2008 r2发布的程序。
2、但终端打印无法打印出来。

跪求:c#如何通过终端的rdp协议封装打印到本地打印机。

  • 写回答

4条回答 默认 最新

  • qq_32554207 2017-12-09 10:54
    关注

    c# 调用zebra打印机指令打印条码,如果直接打印到lpt1端口的打印机,通过copy指令没有问题,

    但如果ZEBRA打印机是通过USB连接,打印机端口为usb001,则程序不能直接拷贝到usb001端口。

    必须先共享本机的usb端口打印机,再将共享后的打印机名连接为LPT端口打印机,则可以成功打印。

    from:

    http://answers.microsoft.com/en-us/windows/forum/windows_7-hardware/how-do-i-print-a-file-to-my-usb-printer-in-windows/cc20646f-686c-4b45-9495-1d833b0f5fda

    一下是设置步骤:

    Set the printer to Shared, and make note of the name that you give it.
    Then go to Start | Run, and enter the line
    NET USE LPT1 \name of your computer\shared name of printer
    You will now be able to issue the command
    COPY /b \path\filename.prn LPT1:

    /b 参数不用也可以。
    private void button1_Click(object sender, EventArgs e)
    {
    string wo = "TEST002";
    string tmpFile = "d:\123.txt";
    string prtName = @"\WIN7-20140313GI\test";
    StringBuilder str = new StringBuilder();

            str.Append("^XA \r\n"); //打印命令开始
            str.Append("^LL 600^FS \r\n");//定义标签长度 105SL 300 DPI (1mm 12pt) 50mm*12
            str.Append("^PW 1200 \r\n");  //定义标签寬度 100mm*12
            str.Append("^FO40,60^A@N,55,35,E:ARIALR.FNT^FDWO:" + wo + "^FS \r\n");//定义坐标,字体
            str.Append("^FO40,150^BY4,4^BCN,100,N,N,N,A^FR^FD" + wo + "^FS \r\n");//128码
            str.Append("^XZ");//结束打印
    
    
    
            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(tmpFile))
            {
                sw.Write(str.ToString());            
            }
    
            System.IO.File.Copy(tmpFile, prtName, true);
        }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 MATLAB动图的问题
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名