| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package com.mes.print.test;
- import com.mes.print.tsc.TSCLIB;
- /**
- * 测试二维码打印
- */
- public class TestQRCode {
- public static void main(String[] args) {
- TSCLIB tsc = TSCLIB.INSTANCE;
- try {
- // 1. 打开打印机
- System.out.println("打开打印机...");
- int result = tsc.openport("TSC TTP-244 PRO");
- if (result != 1) {
- System.err.println("打开打印机失败");
- return;
- }
- // 2. 设置标签参数
- System.out.println("设置标签参数...");
- tsc.setup("76.2", "41.1", "4", "10", "0", "3", "0");
- // 3. 清除缓冲区
- tsc.clearbuffer();
- // 4. 绘制二维码(简单测试)
- System.out.println("绘制二维码...");
- System.out.println(" 位置: (50, 100)");
- System.out.println(" 纠错: L");
- System.out.println(" 单元: 5");
- System.out.println(" 内容: TEST123");
- tsc.qrcode("50", "100", "L", "5", "A", "0", "TEST123");
- // 5. 打印
- System.out.println("开始打印...");
- tsc.printlabel("1", "1");
- // 6. 关闭打印机
- tsc.closeport();
- System.out.println("完成!");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
|