TSC TTP-243E 打印机,打印二维码 图片?

TSCCLIB_DLL:

 public  class TSCLIB_DLL
    {
        [DllImport("TSCLIB.dll", EntryPoint = "about")]
        public static extern int about();

        [DllImport("TSCLIB.dll", EntryPoint = "openport")]
        public static extern int openport(string printername);

        [DllImport("TSCLIB.dll", EntryPoint = "barcode")]
        public static extern int barcode(string x, string y, string type,
                       string height, string readable, string rotation,
                       string narrow, string wide, string code);

        [DllImport("TSCLIB.dll", EntryPoint = "clearbuffer")]
        public static extern int clearbuffer();

        [DllImport("TSCLIB.dll", EntryPoint = "closeport")]
        public static extern int closeport();

        [DllImport("TSCLIB.dll", EntryPoint = "downloadpcx")]
        public static extern int downloadpcx(string filename, string image_name);

        [DllImport("TSCLIB.dll", EntryPoint = "formfeed")]
        public static extern int formfeed();

        [DllImport("TSCLIB.dll", EntryPoint = "nobackfeed")]
        public static extern int nobackfeed();

        [DllImport("TSCLIB.dll", EntryPoint = "printerfont")]
        public static extern int printerfont(string x, string y, string fonttype,
                           string rotation, string xmul, string ymul,
                           string text);

        [DllImport("TSCLIB.dll", EntryPoint = "printlabel")]
        public static extern int printlabel(string set, string copy);

        [DllImport("TSCLIB.dll", EntryPoint = "sendcommand")]
        public static extern int sendcommand(string printercommand);

        [DllImport("TSCLIB.dll", EntryPoint = "setup")]
        public static extern int setup(string width, string height,
                     string speed, string density,
                     string sensor, string vertical,
                     string offset);

        [DllImport("TSCLIB.dll", EntryPoint = "windowsfont")]
        public static extern int windowsfont(int x, int y, int fontheight,
            int rotation, int fontstyle, int fontunderline,
                           string szFaceName, string content);
    }

文本打印正常:

SCLIB_DLL.windowsfont(280, 118, 24, 0, 2, 0, "宋体", "产品颜色");

二维码 图片打印不正常 无法打印出来也没有图片

图片打印

 TSCLIB_DLL.downloadpcx("1.BMP ", " TS1C.BMP ");
 TSCLIB_DLL.sendcommand("PUTBMP 100,100, \" TS1C.BMP \"");

二维码打印

 TSCLIB_DLL.sendcommand("QRCODE 50,50,H,4,A,0,M2,S7,\"123TSCtest\"");

https://www.chinatsc.cn/sites/www.chinatsc.cn/files/users/use...

https://www.chinatsc.cn/sites/www.chinatsc.cn/files/users/use...

完整代码:

    TSCLIB_DLL.openport("TSC TTP-243E");
    TSCLIB_DLL.setup("70", "50", "4", "8", "0", "3.5", "0");
    TSCLIB_DLL.clearbuffer();

   TSCLIB_DLL.windowsfont(280, 70, 24, 0, 2, 0, "宋体", "ASDFAA");
   TSCLIB_DLL.downloadpcx("1.BMP ", " TS1C.BMP ");
   TSCLIB_DLL.sendcommand("PUTBMP 100,100, \" TS1C.BMP \"");

   TSCLIB_DLL.sendcommand("QRCODE 50,50,H,4,A,0,M2,S7,\"123TSCtest\"");

   TSCLIB_DLL.printlabel("1", "1");
   TSCLIB_DLL.closeport();

现在的问题是,除了能打印文本,其他的都不能打印,直接复制官方的文档也不行,我使用的语言是c#。

我是少配置了什么?还是少了什么打印参数?是打印机不支持?

不报错,也打印不出来

阅读 455
avatarAI BotBETA

可能原因及解决方案:

  1. 文件名空格问题
    注意downloadpcx("1.BMP ", " TS1C.BMP ")中文件名前后的空格,应改为:

    TSCLIB_DLL.downloadpcx("1.BMP", "TS1C.BMP"); // 移除所有多余空格
    TSCLIB_DLL.sendcommand("PUTBMP 100,100,\"TS1C.BMP\""); // 文件名保持一致
  2. 二维码命令参数问题
    TSC最新固件要求二维码命令格式为:
    QRCODE X,Y,ECC,CELLSIZE,MODE,ROTATION,MODEL,MASK,"CONTENT"
    尝试修改为:

    TSCLIB_DLL.sendcommand("QRCODE 50,50,H,4,A,0,M2,S3,\"123TSCtest\"");
    // 注意最后的 S3(掩码值)而不是 S7,S7可能不被支持
  3. 图像格式问题

    • 确认图片是单色位图(1-bit BMP)
    • 尺寸不要超过打印区域
    • 建议使用TSC官方工具TSPL View测试图片是否有效
  4. 固件兼容性

    • 检查打印机固件版本(按住PAUSE键开机打印自检页)
    • 如果固件版本低于V4.XX,需升级固件(官网下载)
  5. 替代打印方案
    改用windowsfont打印二维码(需生成二维码图片转为字体):

    TSCLIB_DLL.windowsfont(50, 50, 32, 0, 0, 0, "QRCODE.FNT", "123TSCtest");

完整修正代码示例:

TSCLIB_DLL.openport("TSC TTP-243E");
TSCLIB_DLL.setup("70", "50", "4", "8", "0", "3.5", "0");
TSCLIB_DLL.clearbuffer();

// 打印文本
TSCLIB_DLL.windowsfont(280, 70, 24, 0, 2, 0, "宋体", "ASDFAA");

// 打印图片(确保1.bmp是单色位图)
TSCLIB_DLL.downloadpcx("1.bmp", "TS1C.bmp");
TSCLIB_DLL.sendcommand("PUTBMP 100,100,\"TS1C.bmp\"");

// 打印二维码(H纠错级别,M2自动模式,S3掩码)
TSCLIB_DLL.sendcommand("QRCODE 50,50,H,6,A,0,M2,S3,\"123TSCtest\"");

TSCLIB_DLL.printlabel("1", "1");
TSCLIB_DLL.closeport();

验证步骤:

  1. 先用TSC官方指令工具TSPL测试命令是否有效
  2. 打印自检页确认二维码功能是否正常
  3. 尝试降低打印速度(setup参数第三个值改为"2")

若仍无效,建议检查:

  • 驱动是否安装为官方最新版
  • 换用USB线直连(避免网络打印问题)
  • 尝试在sendcommand后添加DELAY 500等待指令执行

(根据TSC TTP-243E编程手册验证,部分旧型号需要启用二维码功能:sendcommand("QRCODE ON")

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进