printing - 如何避免打印后重启蓝牙打印机?

标签 printing bluetooth windows-mobile-6.5 32feet

我开发了 windows mobile 6.1 应用程序,可以搜索附近的蓝牙设备并发送文件。我还实现了在蓝牙打印机上打印文档的打印功能。

第一次打印功能运行良好,但当我再次打印文档时,我需要重新启动打印机,然后才能打印。

有什么解决方案可以避免重启打印机吗??

下面是我引用的打印代码 https://32feet.codeplex.com/discussions/355451

private void btPrint_Click(object sender, EventArgs e)
    {            
        // Activate BT
        BluetoothRadio.PrimaryRadio.Mode = RadioMode.Connectable;
        System.Threading.Thread.Sleep(1000);
        // Connect  
        BluetoothAddress btAddress;
        btAddress = BluetoothAddress.Parse("0022583165F7");            
        BluetoothClient btClient = new BluetoothClient();
        try
        {
            btClient.Connect(new BluetoothEndPoint(btAddress, BluetoothService.SerialPort));
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
            return;
        }
        // Send data
        string CPCLStr1 =
            "! 0 200 200 210 1" + Environment.NewLine +
            "ML 25" + Environment.NewLine +
            "TEXT 7 0 10 20" + Environment.NewLine +
            "Just" + Environment.NewLine +
            "Testing" + Environment.NewLine +
            "ENDML" + Environment.NewLine +
            "FORM" + Environment.NewLine +
            "PRINT" + Environment.NewLine;

        // Convert CPCL String to byte array
        byte[] CPCLbytes1 = ASCIIEncoding.ASCII.GetBytes(CPCLStr1);

        NetworkStream ns = btClient.GetStream();
        ns.Write(CPCLbytes1, 0, CPCLbytes1.Length);

        btClient.Close();
    }

最佳答案

虽然您关闭了客户端流,但打印机似乎在重置其 session 之前等待了一段时间。

尝试在末尾发送一个字节。

根据 CPCL 引用指南,没有简单的重置命令,例如 ESC/p ({esc}@)。

在每次打印后重置​​设备似乎有点矫枉过正。

编辑:sendFile 的 SDK 示例:

                Byte[] cpclLabel = Encoding.Default.GetBytes("! 0 200 200 406 1\r\n" + "ON-FEED IGNORE\r\n"
                + "BOX 20 20 380 380 8\r\n"
                + "T 0 6 137 177 TEST\r\n"
                + "PRINT\r\n");

以上在我的 RW420 上运行良好,无需在打印之间重置。

关于printing - 如何避免打印后重启蓝牙打印机?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24007391/

相关文章:

android - 将 Android 连接到具有未知 UUID 的设备

c# - 使用 opencf.net.ftp 在 c# 中使用 ftp 上传/下载 for windows mobile 6.5

windows-mobile-6.5 - 使用 Windows Mobile 设备/Windows 7 复制文件

printing - 在 Perl6 中更改 Data::Printer 中的参数

linux - Derby 安 : Forward login console over bluetooth

android - Google Fit API 未从蓝牙腕带 (SWR12) 接收数据

windows-8 - 如何将 Windows Mobile 6 ActiveSync 到 Windows 8

java - 使用 Java 打印到收据打印机时修复文本拉伸(stretch)

matlab - 如何以 Matlab eps 格式导出变音符号(或任何外来字符)?

pandas - 在 iPython Notebook 中将 DataFrame 显示为表格