C# Класс ThermalDotNet.ThermalPrinter

ESP/POS serial thermal printer library. https://github.com/yukimizake/ThermalDotNet
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
PictureLineSleepTimeMs int
WriteLineSleepTimeMs int

Открытые методы

Метод Описание
BoldOff ( ) : void

Sets bold mode off.

BoldOn ( ) : void

Sets bold mode on.

FeedDots ( byte dotsToFeed ) : void

Prints the contents of the buffer and feeds n dots.

HorizontalLine ( int length ) : void

Prints a horizontal line.

Indent ( byte columns ) : void

Idents the text.

LineFeed ( ) : void

Prints the contents of the buffer and feeds one line.

LineFeed ( byte lines ) : void

Prints the contents of the buffer and feeds n lines.

PrintBarcode ( BarcodeType type, string data ) : void

Prints the barcode data.

PrintImage ( Bitmap image ) : void

Prints the image. The image must be 384px wide.

PrintImage ( string fileName ) : void

Prints the image. The image must be 384px wide.

Reset ( ) : void

Resets the printer.

SetAlignCenter ( ) : void

Centers the text.

SetAlignLeft ( ) : void

Aligns the text to the left.

SetAlignRight ( ) : void

Aligns the text to the right.

SetBarcodeLeftSpace ( byte spacingDots ) : void

Sets the barcode left space.

SetLargeBarcode ( bool large ) : void

Selects large barcode mode.

SetLineSpacing ( byte lineSpacing ) : void

Sets the line spacing.

SetPrintingParameters ( byte maxPrintingDots, byte heatingTime, byte heatingInterval ) : void

Sets the printing parameters.

SetSize ( bool doubleWidth, bool doubleHeight ) : void

Sets the text size.

Sleep ( ) : void

Sets the printer offine.

ThermalPrinter ( SerialPort serialPort ) : System

Initializes a new instance of the ThermalDotNet.ThermalPrinter class.

ThermalPrinter ( SerialPort serialPort, byte maxPrintingDots, byte heatingTime, byte heatingInterval ) : System

Initializes a new instance of the ThermalDotNet.ThermalPrinter class.

ToString ( ) : string

Returns a System.String that represents the current ThermalDotNet.ThermalPrinter.

WakeUp ( ) : void

Sets the printer online.

WhiteOnBlackOff ( ) : void

Sets white on black mode off.

WhiteOnBlackOn ( ) : void

Sets white on black mode on.

WriteLine ( string text ) : void

Prints the line of text.

WriteLine ( string text, PrintingStyle style ) : void

Prints the line of text.

WriteLine ( string text, byte style ) : void

Prints the line of text.

WriteLine_Big ( string text ) : void

Prints the line of text, double size.

WriteLine_Bold ( string text ) : void

Prints the line of text in bold.

WriteLine_Invert ( string text ) : void

Prints the line of text, white on black.

WriteToBuffer ( string text ) : void

Sends the text to the printer buffer. Does not print until a line feed (0x10) is sent.

Приватные методы

Метод Описание
_BitClear ( byte originalValue, int bit ) : byte

Return the given value with its n bit cleared.

_BitSet ( byte originalValue, byte bit ) : byte

Return the given value with its n bit set.

_BitTest ( byte valueToTest, int testBit ) : bool

Tests the value of a given bit.

_constructor ( SerialPort serialPort, byte maxPrintingDots, byte heatingTime, byte heatingInterval ) : void
_sendEncoding ( string encoding ) : void
_writeByte ( byte valueToWrite ) : void

Описание методов

BoldOff() публичный Метод

Sets bold mode off.
public BoldOff ( ) : void
Результат void

BoldOn() публичный Метод

Sets bold mode on.
public BoldOn ( ) : void
Результат void

FeedDots() публичный Метод

Prints the contents of the buffer and feeds n dots.
public FeedDots ( byte dotsToFeed ) : void
dotsToFeed byte /// Number of dots to feed. ///
Результат void

HorizontalLine() публичный Метод

Prints a horizontal line.
public HorizontalLine ( int length ) : void
length int /// Line length (in characters) (max 32). ///
Результат void

Indent() публичный Метод

Idents the text.
public Indent ( byte columns ) : void
columns byte /// Number of columns. ///
Результат void

LineFeed() публичный Метод

Prints the contents of the buffer and feeds one line.
public LineFeed ( ) : void
Результат void

LineFeed() публичный Метод

Prints the contents of the buffer and feeds n lines.
public LineFeed ( byte lines ) : void
lines byte /// Number of lines to feed. ///
Результат void

PrintBarcode() публичный Метод

Prints the barcode data.
public PrintBarcode ( BarcodeType type, string data ) : void
type BarcodeType /// Type of barcode. ///
data string /// Data to print. ///
Результат void

PrintImage() публичный Метод

Prints the image. The image must be 384px wide.
public PrintImage ( Bitmap image ) : void
image System.Drawing.Bitmap /// Image to print. ///
Результат void

PrintImage() публичный Метод

Prints the image. The image must be 384px wide.
public PrintImage ( string fileName ) : void
fileName string /// Image file path. ///
Результат void

Reset() публичный Метод

Resets the printer.
public Reset ( ) : void
Результат void

SetAlignCenter() публичный Метод

Centers the text.
public SetAlignCenter ( ) : void
Результат void

SetAlignLeft() публичный Метод

Aligns the text to the left.
public SetAlignLeft ( ) : void
Результат void

SetAlignRight() публичный Метод

Aligns the text to the right.
public SetAlignRight ( ) : void
Результат void

SetBarcodeLeftSpace() публичный Метод

Sets the barcode left space.
public SetBarcodeLeftSpace ( byte spacingDots ) : void
spacingDots byte /// Spacing dots. ///
Результат void

SetLargeBarcode() публичный Метод

Selects large barcode mode.
public SetLargeBarcode ( bool large ) : void
large bool /// Large barcode mode. ///
Результат void

SetLineSpacing() публичный Метод

Sets the line spacing.
public SetLineSpacing ( byte lineSpacing ) : void
lineSpacing byte /// Line spacing (in dots), default value: 32 dots. ///
Результат void

SetPrintingParameters() публичный Метод

Sets the printing parameters.
public SetPrintingParameters ( byte maxPrintingDots, byte heatingTime, byte heatingInterval ) : void
maxPrintingDots byte /// Max printing dots (0-255), unit: (n+1)*8 dots, default: 7 (beceause (7+1)*8 = 64 dots) ///
heatingTime byte /// Heating time (3-255), unit: 10µs, default: 80 (800µs) ///
heatingInterval byte /// Heating interval (0-255), unit: 10µs, default: 2 (20µs) ///
Результат void

SetSize() публичный Метод

Sets the text size.
public SetSize ( bool doubleWidth, bool doubleHeight ) : void
doubleWidth bool /// Double width ///
doubleHeight bool /// Double height ///
Результат void

Sleep() публичный Метод

Sets the printer offine.
public Sleep ( ) : void
Результат void

ThermalPrinter() публичный Метод

Initializes a new instance of the ThermalDotNet.ThermalPrinter class.
public ThermalPrinter ( SerialPort serialPort ) : System
serialPort System.IO.Ports.SerialPort /// Serial port used by printer. ///
Результат System

ThermalPrinter() публичный Метод

Initializes a new instance of the ThermalDotNet.ThermalPrinter class.
public ThermalPrinter ( SerialPort serialPort, byte maxPrintingDots, byte heatingTime, byte heatingInterval ) : System
serialPort System.IO.Ports.SerialPort /// Serial port used by printer. ///
maxPrintingDots byte /// Max printing dots (0-255), unit: (n+1)*8 dots, default: 7 ((7+1)*8 = 64 dots) ///
heatingTime byte /// Heating time (3-255), unit: 10µs, default: 80 (800µs) ///
heatingInterval byte /// Heating interval (0-255), unit: 10µs, default: 2 (20µs) ///
Результат System

ToString() публичный Метод

Returns a System.String that represents the current ThermalDotNet.ThermalPrinter.
public ToString ( ) : string
Результат string

WakeUp() публичный Метод

Sets the printer online.
public WakeUp ( ) : void
Результат void

WhiteOnBlackOff() публичный Метод

Sets white on black mode off.
public WhiteOnBlackOff ( ) : void
Результат void

WhiteOnBlackOn() публичный Метод

Sets white on black mode on.
public WhiteOnBlackOn ( ) : void
Результат void

WriteLine() публичный Метод

Prints the line of text.
public WriteLine ( string text ) : void
text string /// Text to print. ///
Результат void

WriteLine() публичный Метод

Prints the line of text.
public WriteLine ( string text, PrintingStyle style ) : void
text string /// Text to print. ///
style PrintingStyle /// Style of the text. ///
Результат void

WriteLine() публичный Метод

Prints the line of text.
public WriteLine ( string text, byte style ) : void
text string /// Text to print. ///
style byte /// Style of the text. Can be the sum of PrintingStyle enums. ///
Результат void

WriteLine_Big() публичный Метод

Prints the line of text, double size.
public WriteLine_Big ( string text ) : void
text string /// Text to print. ///
Результат void

WriteLine_Bold() публичный Метод

Prints the line of text in bold.
public WriteLine_Bold ( string text ) : void
text string /// Text to print. ///
Результат void

WriteLine_Invert() публичный Метод

Prints the line of text, white on black.
public WriteLine_Invert ( string text ) : void
text string /// Text to print. ///
Результат void

WriteToBuffer() публичный Метод

Sends the text to the printer buffer. Does not print until a line feed (0x10) is sent.
public WriteToBuffer ( string text ) : void
text string /// Text to print. ///
Результат void

Описание свойств

PictureLineSleepTimeMs публичное свойство

Delay between two picture lines. (in ms)
public int PictureLineSleepTimeMs
Результат int

WriteLineSleepTimeMs публичное свойство

Delay between two text lines. (in ms)
public int WriteLineSleepTimeMs
Результат int