Huanent.Printer

封装了PrintDocument类做的小票打印类库。

使用 nuget 安装包 Huanent.Printer 示例代码如下

 public static void PrintOrder(OrderModel order)
        {
            var printer = PrinterFactory.GetPrinter(AppConfig.OrderPrinter, PaperWidth.Paper58mm);
            printer.NewRow();
            printer.NewRow();
            printer.PrintText("malema", Huanent.Printer.Models.FontSize.Huge, StringAlignment.Center);
            printer.NewRow();
            printer.NewRow();
            printer.NewRow();
            printer.PrintText($"总价:{order.TotalPrice.ToString("f2")}");
            printer.PrintText(order.CreatedTime.ToString("yyyy-MM-dd"), stringAlignment: StringAlignment.Far);
            printer.NewRow();
            printer.PrintLine();
            printer.NewRow();
            printer.PrintText("商品");
            printer.PrintText("数量", offset: 0.5f);
            printer.PrintText("总价", stringAlignment: StringAlignment.Far);
            printer.NewRow();
            printer.PrintLine();
            foreach (var item in order.OrderItems)
            {
                printer.NewRow();
                printer.PrintText(item.ProductName, width: 0.5f);
                printer.PrintText(item.Amount.ToString(), width: 0.2f, offset: 0.5F);
                printer.PrintText(item.TotalPrice.ToString("f2"), stringAlignment: StringAlignment.Far);
            }
            printer.NewRow();
            printer.PrintLine();
            printer.NewRow();
            printer.PrintText($"地址:{order.Shop.Address}");
            printer.NewRow();
            printer.PrintText($"联系人:{order.Shop.ContactName}");
            printer.NewRow();
            printer.PrintText($"电话:{order.Shop.Mobile}");
            for (int i = 0; i < AppConfig.orderBottomLlins; i++)
            {
                printer.NewRow();
            }
            if (AppConfig.orderBottomLlins > 0)
            {
                printer.PrintText("...");
            }
            printer.Finish();
        }
上一篇:打印Pdf
最近更新的
...