C# Class ThermalDotNet.ThermalPrinter

ESP/POS serial thermal printer library. https://github.com/yukimizake/ThermalDotNet
Datei anzeigen Open project: yukimizake/ThermalDotNet Class Usage Examples

Public Properties

Property Type Description
PictureLineSleepTimeMs int
WriteLineSleepTimeMs int

Public Methods

Method Description
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.

Private Methods

Method Description
_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

Method Details

BoldOff() public method

Sets bold mode off.
public BoldOff ( ) : void
return void

BoldOn() public method

Sets bold mode on.
public BoldOn ( ) : void
return void

FeedDots() public method

Prints the contents of the buffer and feeds n dots.
public FeedDots ( byte dotsToFeed ) : void
dotsToFeed byte /// Number of dots to feed. ///
return void

HorizontalLine() public method

Prints a horizontal line.
public HorizontalLine ( int length ) : void
length int /// Line length (in characters) (max 32). ///
return void

Indent() public method

Idents the text.
public Indent ( byte columns ) : void
columns byte /// Number of columns. ///
return void

LineFeed() public method

Prints the contents of the buffer and feeds one line.
public LineFeed ( ) : void
return void

LineFeed() public method

Prints the contents of the buffer and feeds n lines.
public LineFeed ( byte lines ) : void
lines byte /// Number of lines to feed. ///
return void

PrintBarcode() public method

Prints the barcode data.
public PrintBarcode ( BarcodeType type, string data ) : void
type BarcodeType /// Type of barcode. ///
data string /// Data to print. ///
return void

PrintImage() public method

Prints the image. The image must be 384px wide.
public PrintImage ( Bitmap image ) : void
image System.Drawing.Bitmap /// Image to print. ///
return void

PrintImage() public method

Prints the image. The image must be 384px wide.
public PrintImage ( string fileName ) : void
fileName string /// Image file path. ///
return void

Reset() public method

Resets the printer.
public Reset ( ) : void
return void

SetAlignCenter() public method

Centers the text.
public SetAlignCenter ( ) : void
return void

SetAlignLeft() public method

Aligns the text to the left.
public SetAlignLeft ( ) : void
return void

SetAlignRight() public method

Aligns the text to the right.
public SetAlignRight ( ) : void
return void

SetBarcodeLeftSpace() public method

Sets the barcode left space.
public SetBarcodeLeftSpace ( byte spacingDots ) : void
spacingDots byte /// Spacing dots. ///
return void

SetLargeBarcode() public method

Selects large barcode mode.
public SetLargeBarcode ( bool large ) : void
large bool /// Large barcode mode. ///
return void

SetLineSpacing() public method

Sets the line spacing.
public SetLineSpacing ( byte lineSpacing ) : void
lineSpacing byte /// Line spacing (in dots), default value: 32 dots. ///
return void

SetPrintingParameters() public method

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) ///
return void

SetSize() public method

Sets the text size.
public SetSize ( bool doubleWidth, bool doubleHeight ) : void
doubleWidth bool /// Double width ///
doubleHeight bool /// Double height ///
return void

Sleep() public method

Sets the printer offine.
public Sleep ( ) : void
return void

ThermalPrinter() public method

Initializes a new instance of the ThermalDotNet.ThermalPrinter class.
public ThermalPrinter ( SerialPort serialPort ) : System
serialPort System.IO.Ports.SerialPort /// Serial port used by printer. ///
return System

ThermalPrinter() public method

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) ///
return System

ToString() public method

Returns a System.String that represents the current ThermalDotNet.ThermalPrinter.
public ToString ( ) : string
return string

WakeUp() public method

Sets the printer online.
public WakeUp ( ) : void
return void

WhiteOnBlackOff() public method

Sets white on black mode off.
public WhiteOnBlackOff ( ) : void
return void

WhiteOnBlackOn() public method

Sets white on black mode on.
public WhiteOnBlackOn ( ) : void
return void

WriteLine() public method

Prints the line of text.
public WriteLine ( string text ) : void
text string /// Text to print. ///
return void

WriteLine() public method

Prints the line of text.
public WriteLine ( string text, PrintingStyle style ) : void
text string /// Text to print. ///
style PrintingStyle /// Style of the text. ///
return void

WriteLine() public method

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. ///
return void

WriteLine_Big() public method

Prints the line of text, double size.
public WriteLine_Big ( string text ) : void
text string /// Text to print. ///
return void

WriteLine_Bold() public method

Prints the line of text in bold.
public WriteLine_Bold ( string text ) : void
text string /// Text to print. ///
return void

WriteLine_Invert() public method

Prints the line of text, white on black.
public WriteLine_Invert ( string text ) : void
text string /// Text to print. ///
return void

WriteToBuffer() public method

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. ///
return void

Property Details

PictureLineSleepTimeMs public_oe property

Delay between two picture lines. (in ms)
public int PictureLineSleepTimeMs
return int

WriteLineSleepTimeMs public_oe property

Delay between two text lines. (in ms)
public int WriteLineSleepTimeMs
return int