用于远程打印的sbpl模块
sbpl的Python项目详细描述
收缩压
用于远程打印的sbpl模块
摘要
这提供了直接远程打印的功能 使用SBPL到局域网上的打印机 (Sato条码打印机语言)由Sato公司提供。
这使得无法控制的任意标签剪切 用普通的windows打印机。
此模块具有使用FreeType打印TrueType字体的功能。执行方法ttf_write()。
这个模块是一个原型,可能不能满足您的工作, 但由于它是纯python,所以您可以自己添加和更改特性。
安装
$ pip install sbpl
用法
fromsbplimport*comm=SG412R_Status5()withcomm.open("192.168.0.251",1024):comm.prepare()# generate label...gen=LabelGenerator()withgen.packet_for_with():withgen.page_for_with():gen.set_label_size((1000,3000))gen.rotate_270()gen.pos((260,930))gen.codebar(("0004693003005000",3,100))gen.pos((160,1000))gen.expansion((1,1))gen.bold_text("0004693003005000")gen.print()comm.send(gen.to_bytes())comm.finish()
您可以用json格式描述打印内容,并将它们一起指定。
json:
[{"host":"192.168.0.251","port":1024,"communication":"SG412R_Status5"},[{"set_label_size":[1000,3000]},{"shift_jis":0},{"rotate_270":0},{"comment":"==ticket main=="},{"pos":[710,130],"expansion":[6000],"ttf_write":"TEST CONSERT","font":"mplus-1p-medium.ttf"},{"pos":[530,1040],"expansion":[2700],"ttf_write":"Organizer: Python High School","font":"mplus-1p-medium.ttf"},{"pos":[370,50],"expansion":[3700],"ttf_write":"Friday, February 14, 2014 14:00","font":"mplus-1p-medium.ttf"},{"pos":[300,80],"expansion":[2800],"ttf_write":"Indoor playground","font":"mplus-1p-medium.ttf"},{"pos":[230,30],"expansion":[3500],"ttf_write":"Free seat $5.00","font":"mplus-1p-medium.ttf"},{"pos":[180,50],"expansion":[1800],"ttf_write":"Drinks can be brought in but alcohol is prohibited.","font":"mplus-1p-medium.ttf"},{"comment":"==barcode=="},{"pos":[260,930],"codebar":["0004693003005000",3,100]},{"pos":[160,1000],"expansion":[1,1],"bold_text":"0004693003005000"},{"comment":"==ticket parted=="},{"pos":[780,1610],"expansion":[2500],"ttf_write":"TEST","font":"mplus-1p-medium.ttf"},{"pos":[670,1610],"expansion":[2500],"ttf_write":"CONSERT","font":"mplus-1p-medium.ttf"},{"pos":[620,1630],"expansion":[2000],"ttf_write":"Friday, February 14, 2014 14:00","font":"mplus-1p-medium.ttf"},{"pos":[580,1630],"expansion":[2000],"ttf_write":"14:00","font":"mplus-1p-medium.ttf"},{"pos":[420,1610],"expansion":[2000],"ttf_write":"Free seat","font":"mplus-1p-medium.ttf"},{"pos":[330,1600],"expansion":[2000],"ttf_write":"$5.00","font":"mplus-1p-medium.ttf"},{"print":1}]]
Python:
fromsbplimport*json_str="(defined adobe)"comm=SG412R_Status5()gen=LabelGenerator()parser=JsonParser(gen)parser.parse(json_str)parser.post(comm)
许可证
麻省理工学院
作者
版权所有2018 kato kanryu(k.kanryu@gmail.com)