Git Product home page Git Product logo

huanent.printer's Introduction

旧版本文档

1.1版本文档

当前版本

huanent.printer2.0版本是对1.1版本的破坏性更新,两个版本不兼容,2.0版本提供了更好的打印控制,如自动换行,流式打印等。

基本使用教程

安装程序集

在nuget搜索Huanent.Printer进行安装,考虑到市场上还存在xp系统的打印机,故最低支持到.net4.0版本

获取本机所有打印机列表

var list= PrintQueueHelper.GetPrintQueueName();

此方法获取到本机所有打印机驱动的名称,选择小票打印机的名字例如 xp58

获得打印机对象

var printer = PrinterFactory.GetPrinter("xp58", PaperWidth.Paper80mm);

进行打印

PrintQueueHelper.GetPrintQueueName();
var printer = PrinterFactory.GetPrinter("Microsoft XPS Document Writer", PaperWidth.Paper80mm);
printer.NewRow();
printer.NewRow();
printer.PrintText("永辉超市", FontSize.Huge, StringAlignment.Center);
printer.NewRow();
printer.NewRow();
printer.NewRow();
printer.PrintText("操作员:张三");
printer.PrintText(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), stringAlignment: StringAlignment.Far);
printer.NewRow();
printer.PrintLine();
printer.NewRow();
printer.PrintText("商品");
printer.PrintText("单价", offset: 0.35f);
printer.PrintText("数量", offset: 0.65f);
printer.PrintText("总价", stringAlignment: StringAlignment.Far);
printer.NewRow();
printer.PrintLine();
printer.NewRow();
printer.PrintText("**长白山大萝卜,跳楼吐血大甩卖,不甜不要钱**", width: 0.35f);
printer.PrintText("6.00", width: 0.2f, offset: 0.35f);
printer.PrintText("2.00", width: 0.2f, offset: 0.65F);
printer.PrintText("12.00", stringAlignment: StringAlignment.Far);
printer.NewRow();
printer.NewRow();
printer.PrintText("大螃蟹", width: 0.35f);
printer.PrintText("6.000000000001", width: 0.2f, offset: 0.35f);
printer.PrintText("1", width: 0.2f, offset: 0.65F);
printer.PrintText("6.000000000001", offset: 0.8f, width: 0.2f);
printer.NewRow();
printer.PrintLine();
printer.NewRow();
var bitmap = new Bitmap("qr.png");
printer.PrintImage(bitmap, StringAlignment.Center);
printer.PrintText("关注超市->");
printer.NewRow();
printer.PrintLine();
printer.NewRow();
printer.PrintText("感谢光临,欢迎下次再来!", stringAlignment: StringAlignment.Center);
printer.NewRow();
printer.Finish();

最终成品为下图

huanent.printer's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.