一、蓝牙打印机配对
登录Cloud 工作台 -》设置 -》蓝牙打印设置,如下图:
二、插件代码示例:
1、打印文本
var helper = PrintHelper.CreateHelper(this.Context, "");
var prtEntity = helper.CreateEntity();
prtEntity.ElementCollection.Add(helper.GetFormatString("HelloWorld!"));
this.View.MobilePrint(prtEntity);
2、打印条形码
var helper = PrintHelper.CreateHelper(this.Context, "");
var prtEntity = helper.CreateEntity();
prtEntity.ElementCollection.Add(helper.GetFormat1DBarcode("123456789012"));
this.View.MobilePrint(prtEntity);
3、打印二维码
var helper = PrintHelper.CreateHelper(this.Context, "");
var prtEntity = helper.CreateEntity();
prtEntity.ElementCollection.Add(helper.GetFormat2DBarcode("HelloWorld!"));
this.View.MobilePrint(prtEntity);
4、打印图片("image/print"图片所在目录,"print.gif"图片名称)
var helper = PrintHelper.CreateHelper(this.Context, "");
var prtEntity = helper.CreateEntity();
prtEntity.ElementCollection.Add(helper.GetFormatPicture(PathUtils.GetPhysicalPath(@"image/print", "print.gif")));
this.View.MobilePrint(prtEntity);
5、按模板打印
“MOB_PrintShop”为打印模板。
模板定义路径:Administrator登录系统,主控台 -》 基础管理 -》 公共设置 -》 移动平台设置 -》 移动打印格式模板列表。
var sphelper = PrintHelper.CreateHelper(this.Context, "MOB_PrintShop");
var spprtEntity = sphelper.CreateEntity();
if (spprtEntity.Header.IsEmpty())
{
var headerString = sphelper.GetFormatString("金蝶商城");
headerString.Format.AntiWhite = true;
headerString.Format.DoubleWidth = true;
spprtEntity.Header.Add(headerString);
spprtEntity.Header.Add(sphelper.GetFormatString("----------------------------"));
if (spprtEntity.Footer.IsEmpty())
{
spprtEntity.Footer.Add(sphelper.GetFormatString("----------------------------"));
}
}
spprtEntity.ElementCollection.Add(sphelper.GetFormatCollumns(new[] { "拖把(促销)", "$100", "2.0" }));
spprtEntity.ElementCollection.Add(sphelper.GetFormatCollumns(new[] { "叼牌洗面奶(促销)", "$200", "5.0" }));spprtEntity.ElementCollection.Add(sphelper.GetFormatCollumns(new[] { "购物袋", "$2", "1.0" }));spprtEntity.ElementCollection.Add(sphelper.GetFormatCollumns(new[] {"HelloWorld", "$100", "2.0" }));spprtEntity.ElementCollection.Add(sphelper.GetFormatCollumns(new[] { "Oh中文MyGod.", "$100", "2.0" }));
spprtEntity.ElementCollection.Add(sphelper.GetFormatCollumns(new[] { "你好吗?这是超长商品名称,谢谢光顾!", "$2", "1.0" }));
this.View.MobilePrint(spprtEntity);
适配的打印机是北京瑞工科技的RG-MTP58B-SUBT。
推荐阅读