1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| package com.tscsdk.mytest; import com.sun.jna.Library; import com.sun.jna.Native;
public class PrintFontTest { public interface TscLibDll extends Library { TscLibDll INSTANCE = Native.loadLibrary("\\TSCLIB", TscLibDll.class); int openport(String printerName); void closeport(); void sendcommand(String command); void printerfont(String x, String y, String fontType, String rotation, String xMultiplication, String yMultiplication, String content); int clearbuffer (); int windowsfont (int x, int y, int fontheight, int rotation, int fontstyle, int fontunderline, String szFaceName, String content); int printlabel (String set, String copy); int windowsfontUnicodeLengh(int x, int y, int fontheight, int rotation, int fontstyle, int fontunderline, String szFaceName, byte[] content, int length);
} public static void main(String[] args) { String printerName = "TSC TTP-342 Pro"; int result = TscLibDll.INSTANCE.openport(printerName); if (result != 1) { System.out.println("打印机状态不正确...."); return; } TscLibDll.INSTANCE.sendcommand("SIZE 60 mm, 40 mm"); TscLibDll.INSTANCE.sendcommand("SPEED 3"); TscLibDll.INSTANCE.sendcommand("DENSITY 12"); TscLibDll.INSTANCE.sendcommand("DIRECTION 1"); TscLibDll.INSTANCE.sendcommand("SET TEAR ON"); TscLibDll.INSTANCE.sendcommand("CODEPAGE UTF-8");
TscLibDll.INSTANCE.clearbuffer(); String preContent = "GD90090716QQQQQQQ"; for (int i = 1;i < 3;i++){ TscLibDll.INSTANCE.clearbuffer(); String gdArchiveNo = preContent + (i+""); System.out.println("archiveNo::" + gdArchiveNo); TscLibDll.INSTANCE.windowsfont(60, 200, 60, 0, 0, 0, "Arial", gdArchiveNo); TscLibDll.INSTANCE.printlabel("1", "1"); } TscLibDll.INSTANCE.closeport(); } }
|