有一种可直接打印条码的打印机,本文采用这种方式,
这种打印机,可直接打印条形码,二维码,还可打印文字,图片(PCX,BMP)
有客户端软件,可设计打印的东西,并打印,
也有编程接口,需加载dll,貌似没有linux版的
打印机有USB接口,也有带网线的,我选的带网线的,
打印纸用的是热敏打印机,打印纸有多种规格的,
打印效果
条码:
标签(带条码):打印的是文字,横线(也可也打下划线),条码,
折行的是截取字符串后,在另一行打印的,
佳博打印机官网
/pro.asp?op=2&anid=70
GP-3150TIN条码打印机
/pro_view.asp?op=2&id=59&anid=70&nid=135
带USB口,带网口,还有好几个带网口的,这个最便宜 500左右。
编程接口
动态链接库TSCLIB.dll,支持大部分佳博打印机,和其他品牌的TSC系列的打印机
Windows DLL version V2.00.
下载地址
/detail/haveqing/8822409
有文档和样例,包括JAVA调用,JSP掉用,其他语言调用的,
(JSP调用是用js在前端调用,通过控件调用)
JAVA样例
import com.sun.jna.Library;import com.sun.jna.Native;/*** 打印序列号* @author happyqing* .5.28*/public class PrintLabel {/*** 加载打印Dll,打印接口**/public interface TscLibDll extends Library {//把TSCLIB.dll发到JAVA_HOME\bin下TscLibDll INSTANCE = (TscLibDll) Native.loadLibrary ("TSCLIB", TscLibDll.class);// TscLibDll INSTANCE = (TscLibDll) Native.loadLibrary ("C:\\Windows\\System32\\TSCLIB.dll", TscLibDll.class);int about ();int openport (String pirnterName);int closeport ();int sendcommand (String printerCommand);int setup (String width,String height,String speed,String density,String sensor,String vertical,String offset);int downloadpcx (String filename,String image_name);int barcode (String x,String y,String type,String height,String readable,String rotation,String narrow,String wide,String code);int printerfont (String x,String y,String fonttype,String rotation,String xmul,String ymul,String text);int clearbuffer ();int printlabel (String set, String copy);int formfeed ();int nobackfeed ();int windowsfont (int x, int y, int fontheight, int rotation, int fontstyle, int fontunderline, String szFaceName, String content);}//厂商提供的测试方法public static void main(String[] args) {TscLibDll.INSTANCE.about();TscLibDll.INSTANCE.openport("TSC TTP-2410M");//TscLibDll.INSTANCE.downloadpcx("C:\\UL.PCX", "UL.PCX");TscLibDll.INSTANCE.sendcommand("REM ***** This is a test by JAVA. *****");TscLibDll.INSTANCE.setup("100", "100", "5", "8", "0", "0", "0");TscLibDll.INSTANCE.clearbuffer();//TscLibDll.INSTANCE.sendcommand("PUTPCX 550,10,\"UL.PCX\"");TscLibDll.INSTANCE.printerfont ("100", "10", "3", "0", "1", "1", "(JAVA) DLL Test!!");TscLibDll.INSTANCE.barcode("100", "40", "128", "50", "1", "0", "2", "2", "123456789");TscLibDll.INSTANCE.windowsfont(400, 200, 48, 0, 3, 1, "arial", "DEG 0");TscLibDll.INSTANCE.windowsfont(400, 200, 48, 90, 3, 1, "arial", "DEG 90");TscLibDll.INSTANCE.windowsfont(400, 200, 48, 180, 3, 1, "arial", "DEG 180");TscLibDll.INSTANCE.windowsfont(400, 200, 48, 270, 3, 1, "arial", "DEG 270");TscLibDll.INSTANCE.printlabel("1", "1");TscLibDll.INSTANCE.closeport();}}
注意:要是打印乱码
请把JAVA文件编译成GBK的class,就好了,不只是设置编码
比如一种方式 VM arguments 加-Dfile.encoding=GBK
附件中提供打印以上两个样例图片的java类(PrintLabel.java),Dto类类似于Map