escpos-php
Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
Mike42\Escpos\Printer Class Reference

Main class for ESC/POS code generation. More...

Inheritance diagram for Mike42\Escpos\Printer:
Inheritance graph
[legend]

Public Member Functions

 __construct (PrintConnector $connector, CapabilityProfile $profile=null)
 Construct a new print object. More...
 
 barcode (string $content, int $type=Printer::BARCODE_CODE39)
 Print a barcode. More...
 
 bitImage (EscposImage $img, int $size=Printer::IMG_DEFAULT)
 Print an image, using the older "bit image" command. More...
 
 bitImageColumnFormat (EscposImage $img, int $size=Printer::IMG_DEFAULT)
 Print an image, using the older "bit image" command in column format. More...
 
 close ()
 Close the underlying buffer. More...
 
 cut (int $mode=Printer::CUT_FULL, int $lines=3)
 Cut the paper. More...
 
 feed (int $lines=1)
 Print and feed line / Print and feed n lines. More...
 
 feedForm ()
 Some printers require a form feed to release the paper. More...
 
 release ()
 Some slip printers require ESC q sequence to release the paper.
 
 feedReverse (int $lines=1)
 Print and reverse feed n lines. More...
 
 getCharacterTable ()
 
 getPrintBuffer ()
 
 getPrintConnector ()
 
 getPrinterCapabilityProfile ()
 
 graphics (EscposImage $img, int $size=Printer::IMG_DEFAULT)
 Print an image to the printer. More...
 
 initialize ()
 Initialize printer. More...
 
 pdf417Code (string $content, int $width=3, int $heightMultiplier=3, int $dataColumnCount=0, float $ec=0.10, int $options=Printer::PDF417_STANDARD)
 Print a two-dimensional data code using the PDF417 standard. More...
 
 pulse (int $pin=0, int $on_ms=120, int $off_ms=240)
 Generate a pulse, for opening a cash drawer if one is connected. More...
 
 qrCode (string $content, int $ec=Printer::QR_ECLEVEL_L, int $size=3, int $model=Printer::QR_MODEL_2)
 Print the given data as a QR code on the printer. More...
 
 selectCharacterTable (int $table=0)
 Switch character table (code page) manually. More...
 
 selectPrintMode (int $mode=Printer::MODE_FONT_A)
 Select print mode(s). More...
 
 selectUserDefinedCharacterSet ($on=true)
 Select user-defined character set. More...
 
 setBarcodeHeight (int $height=8)
 Set barcode height. More...
 
 setBarcodeWidth (int $width=3)
 Set barcode bar width. More...
 
 setBarcodeTextPosition (int $position=Printer::BARCODE_TEXT_NONE)
 Set the position for the Human Readable Interpretation (HRI) of barcode characters. More...
 
 setDoubleStrike (bool $on=true)
 Turn double-strike mode on/off. More...
 
 setColor (int $color=Printer::COLOR_1)
 Select print color on printers that support multiple colors. More...
 
 setEmphasis (bool $on=true)
 Turn emphasized mode on/off. More...
 
 setFont (int $font=Printer::FONT_A)
 Select font. More...
 
 setJustification (int $justification=Printer::JUSTIFY_LEFT)
 Select justification. More...
 
 setLineSpacing (int $height=null)
 Set the height of the line. More...
 
 setPrintLeftMargin (int $margin=0)
 Set print area left margin. More...
 
 setPrintWidth (int $width=512)
 Set print area width. More...
 
 setPrintBuffer (PrintBuffer $buffer)
 Attach a different print buffer to the printer. More...
 
 setReverseColors (bool $on=true)
 Set black/white reverse mode on or off. More...
 
 setTextSize (int $widthMultiplier, int $heightMultiplier)
 Set the size of text, as a multiple of the normal size. More...
 
 setUnderline (int $underline=Printer::UNDERLINE_SINGLE)
 Set underline for printed text. More...
 
 setUpsideDown (bool $on=true)
 Print each line upside-down (180 degrees rotated). More...
 
 text (string $str)
 Add text to the buffer. More...
 
 textChinese (string $str="")
 Add Chinese text to the buffer. More...
 
 textRaw (string $str="")
 Add text to the buffer without attempting to interpret chararacter codes. More...
 

Public Attributes

const NUL = "\x00"
 ASCII null control character.
 
const LF = "\x0a"
 ASCII linefeed control character.
 
const ESC = "\x1b"
 ASCII escape control character.
 
const FS = "\x1c"
 ASCII form separator control character.
 
const FF = "\x0c"
 ASCII form feed control character.
 
const GS = "\x1d"
 ASCII group separator control character.
 
const DLE = "\x10"
 ASCII data link escape control character.
 
const EOT = "\x04"
 ASCII end of transmission control character.
 
const BARCODE_UPCA = 65
 Indicates UPC-A barcode when used with Printer::barcode.
 
const BARCODE_UPCE = 66
 Indicates UPC-E barcode when used with Printer::barcode.
 
const BARCODE_JAN13 = 67
 Indicates JAN13 barcode when used with Printer::barcode.
 
const BARCODE_JAN8 = 68
 Indicates JAN8 barcode when used with Printer::barcode.
 
const BARCODE_CODE39 = 69
 Indicates CODE39 barcode when used with Printer::barcode.
 
const BARCODE_ITF = 70
 Indicates ITF barcode when used with Printer::barcode.
 
const BARCODE_CODABAR = 71
 Indicates CODABAR barcode when used with Printer::barcode.
 
const BARCODE_CODE93 = 72
 Indicates CODE93 barcode when used with Printer::barcode.
 
const BARCODE_CODE128 = 73
 Indicates CODE128 barcode when used with Printer::barcode.
 
const BARCODE_TEXT_NONE = 0
 Indicates that HRI (human-readable interpretation) text should not be printed, when used with Printer::setBarcodeTextPosition.
 
const BARCODE_TEXT_ABOVE = 1
 Indicates that HRI (human-readable interpretation) text should be printed above a barcode, when used with Printer::setBarcodeTextPosition.
 
const BARCODE_TEXT_BELOW = 2
 Indicates that HRI (human-readable interpretation) text should be printed below a barcode, when used with Printer::setBarcodeTextPosition.
 
const COLOR_1 = 0
 Use the first color (usually black), when used with Printer::setColor.
 
const COLOR_2 = 1
 Use the second color (usually red or blue), when used with Printer::setColor.
 
const CUT_FULL = 65
 Make a full cut, when used with Printer::cut.
 
const CUT_PARTIAL = 66
 Make a partial cut, when used with Printer::cut.
 
const FONT_A = 0
 Use Font A, when used with Printer::setFont.
 
const FONT_B = 1
 Use Font B, when used with Printer::setFont.
 
const FONT_C = 2
 Use Font C, when used with Printer::setFont.
 
const IMG_DEFAULT = 0
 Use default (high density) image size, when used with Printer::graphics, Printer::bitImage or Printer::bitImageColumnFormat.
 
const IMG_DOUBLE_WIDTH = 1
 Use lower horizontal density for image printing, when used with Printer::graphics, Printer::bitImage or Printer::bitImageColumnFormat.
 
const IMG_DOUBLE_HEIGHT = 2
 Use lower vertical density for image printing, when used with Printer::graphics, Printer::bitImage or Printer::bitImageColumnFormat.
 
const JUSTIFY_LEFT = 0
 Align text to the left, when used with Printer::setJustification.
 
const JUSTIFY_CENTER = 1
 Center text, when used with Printer::setJustification.
 
const JUSTIFY_RIGHT = 2
 Align text to the right, when used with Printer::setJustification.
 
const MODE_FONT_A = 0
 Use Font A, when used with Printer::selectPrintMode.
 
const MODE_FONT_B = 1
 Use Font B, when used with Printer::selectPrintMode.
 
const MODE_EMPHASIZED = 8
 Use text emphasis, when used with Printer::selectPrintMode.
 
const MODE_DOUBLE_HEIGHT = 16
 Use double height text, when used with Printer::selectPrintMode.
 
const MODE_DOUBLE_WIDTH = 32
 Use double width text, when used with Printer::selectPrintMode.
 
const MODE_UNDERLINE = 128
 Underline text, when used with Printer::selectPrintMode.
 
const PDF417_STANDARD = 0
 Indicates standard PDF417 code.
 
const PDF417_TRUNCATED = 1
 Indicates truncated PDF417 code.
 
const QR_ECLEVEL_L = 0
 Indicates error correction level L when used with Printer::qrCode.
 
const QR_ECLEVEL_M = 1
 Indicates error correction level M when used with Printer::qrCode.
 
const QR_ECLEVEL_Q = 2
 Indicates error correction level Q when used with Printer::qrCode.
 
const QR_ECLEVEL_H = 3
 Indicates error correction level H when used with Printer::qrCode.
 
const QR_MODEL_1 = 1
 Indicates QR model 1 when used with Printer::qrCode.
 
const QR_MODEL_2 = 2
 Indicates QR model 2 when used with Printer::qrCode.
 
const QR_MICRO = 3
 Indicates micro QR code when used with Printer::qrCode.
 
const STATUS_PRINTER = 1
 Indicates a request for printer status when used with Printer::getPrinterStatus (experimental)
 
const STATUS_OFFLINE_CAUSE = 2
 Indicates a request for printer offline cause when used with Printer::getPrinterStatus (experimental)
 
const STATUS_ERROR_CAUSE = 3
 Indicates a request for error cause when used with Printer::getPrinterStatus (experimental)
 
const STATUS_PAPER_ROLL = 4
 Indicates a request for error cause when used with Printer::getPrinterStatus (experimental)
 
const STATUS_INK_A = 7
 Indicates a request for ink A status when used with Printer::getPrinterStatus (experimental)
 
const STATUS_INK_B = 6
 Indicates a request for ink B status when used with Printer::getPrinterStatus (experimental)
 
const STATUS_PEELER = 8
 Indicates a request for peeler status when used with Printer::getPrinterStatus (experimental)
 
const UNDERLINE_NONE = 0
 Indicates no underline when used with Printer::setUnderline.
 
const UNDERLINE_SINGLE = 1
 Indicates single underline when used with Printer::setUnderline.
 
const UNDERLINE_DOUBLE = 2
 Indicates double underline when used with Printer::setUnderline.
 

Protected Member Functions

 wrapperSend2dCodeData (string $fn, string $cn, string $data='', string $m='')
 Wrapper for GS ( k, to calculate and send correct data length. More...
 
 wrapperSendGraphicsData (string $m, string $fn, string $data='')
 Wrapper for GS ( L, to calculate and send correct data length. More...
 

Static Protected Member Functions

static dataHeader (array $inputs, bool $long=true)
 Convert widths and heights to characters. More...
 
static intLowHigh (int $input, int $length)
 Generate two characters for a number: In lower and higher parts, or more parts as needed. More...
 
static validateBoolean (bool $test, string $source)
 Throw an exception if the argument given is not a boolean. More...
 
static validateFloat (float $test, float $min, float $max, string $source, string $argument="Argument")
 Throw an exception if the argument given is not a float within the specified range. More...
 
static validateInteger (int $test, int $min, int $max, string $source, string $argument="Argument")
 Throw an exception if the argument given is not an integer within the specified range. More...
 
static validateIntegerMulti (int $test, array $ranges, string $source, string $argument="Argument")
 Throw an exception if the argument given is not an integer within one of the specified ranges. More...
 
static validateStringRegex (string $test, string $source, string $regex, string $argument="Argument")
 Throw an exception if the argument doesn't match the given regex. More...
 

Protected Attributes

 $buffer
 The printer's output buffer.
 
 $connector
 Connector showing how to print to this printer.
 
 $profile
 Profile showing supported features for this printer.
 
 $characterTable
 Current character code table.
 

Detailed Description

Main class for ESC/POS code generation.

Constructor & Destructor Documentation

◆ __construct()

Mike42\Escpos\Printer::__construct ( PrintConnector  $connector,
CapabilityProfile  $profile = null 
)

Construct a new print object.

Parameters
PrintConnector$connectorThe PrintConnector to send data to. If not set, output is sent to standard output.
CapabilityProfile | null$profileSupported features of this printer. If not set, the "default" CapabilityProfile will be used, which is suitable for Epson printers.
Exceptions
InvalidArgumentException

Member Function Documentation

◆ barcode()

Mike42\Escpos\Printer::barcode ( string  $content,
int  $type = Printer::BARCODE_CODE39 
)

Print a barcode.

Parameters
string$contentThe information to encode.
int$typeThe barcode standard to output. Supported values are Printer::BARCODE_UPCA, Printer::BARCODE_UPCE, Printer::BARCODE_JAN13, Printer::BARCODE_JAN8, Printer::BARCODE_CODE39, Printer::BARCODE_ITF, Printer::BARCODE_CODABAR, Printer::BARCODE_CODE93, and Printer::BARCODE_CODE128. If not specified, Printer::BARCODE_CODE39 will be used. Note that some barcode formats only support specific lengths or sets of characters, and that available barcode types vary between printers.
Exceptions
InvalidArgumentExceptionWhere the length or characters used in $content is invalid for the requested barcode format.

◆ bitImage()

Mike42\Escpos\Printer::bitImage ( EscposImage  $img,
int  $size = Printer::IMG_DEFAULT 
)

Print an image, using the older "bit image" command.

This creates padding on the right of the image, if its width is not divisible by 8.

Should only be used if your printer does not support the graphics() command. See also bitImageColumnFormat().

Parameters
EscposImage$imgThe image to print
int$sizeSize modifier for the image. Must be either Printer::IMG_DEFAULT (default), or any combination of the Printer::IMG_DOUBLE_HEIGHT and Printer::IMG_DOUBLE_WIDTH flags.

◆ bitImageColumnFormat()

Mike42\Escpos\Printer::bitImageColumnFormat ( EscposImage  $img,
int  $size = Printer::IMG_DEFAULT 
)

Print an image, using the older "bit image" command in column format.

Should only be used if your printer does not support the graphics() or bitImage() commands.

Parameters
EscposImage$imgThe image to print
int$sizeSize modifier for the image. Must be either Printer::IMG_DEFAULT (default), or any combination of the Printer::IMG_DOUBLE_HEIGHT and Printer::IMG_DOUBLE_WIDTH flags.

◆ close()

Mike42\Escpos\Printer::close ( )

Close the underlying buffer.

With some connectors, the job will not actually be sent to the printer until this is called.

◆ cut()

Mike42\Escpos\Printer::cut ( int  $mode = Printer::CUT_FULL,
int  $lines = 3 
)

Cut the paper.

Parameters
int$modeCut mode, either Printer::CUT_FULL or Printer::CUT_PARTIAL. If not specified, Printer::CUT_FULL will be used.
int$linesNumber of lines to feed

◆ dataHeader()

static Mike42\Escpos\Printer::dataHeader ( array  $inputs,
bool  $long = true 
)
staticprotected

Convert widths and heights to characters.

Used before sending graphics to set the size.

Parameters
array$inputs
boolean$longTrue to use 4 bytes, false to use 2
Returns
string

◆ feed()

Mike42\Escpos\Printer::feed ( int  $lines = 1)

Print and feed line / Print and feed n lines.

Parameters
int$linesNumber of lines to feed

◆ feedForm()

Mike42\Escpos\Printer::feedForm ( )

Some printers require a form feed to release the paper.

On most printers, this command is only useful in page mode, which is not implemented in this driver.

◆ feedReverse()

Mike42\Escpos\Printer::feedReverse ( int  $lines = 1)

Print and reverse feed n lines.

Parameters
int$linesnumber of lines to feed. If not specified, 1 line will be fed.

◆ getCharacterTable()

Mike42\Escpos\Printer::getCharacterTable ( )
Returns
int

◆ getPrintBuffer()

Mike42\Escpos\Printer::getPrintBuffer ( )
Returns
PrintBuffer

◆ getPrintConnector()

Mike42\Escpos\Printer::getPrintConnector ( )
Returns
PrintConnector

◆ getPrinterCapabilityProfile()

Mike42\Escpos\Printer::getPrinterCapabilityProfile ( )

◆ graphics()

Mike42\Escpos\Printer::graphics ( EscposImage  $img,
int  $size = Printer::IMG_DEFAULT 
)

Print an image to the printer.

Size modifiers are:

See the example/ folder for detailed examples.

The functions bitImage() and bitImageColumnFormat() take the same parameters, and can be used if your printer doesn't support the newer graphics commands.

Parameters
EscposImage$imgThe image to print.
int$sizeSize modifier for the image. Must be either Printer::IMG_DEFAULT (default), or any combination of the Printer::IMG_DOUBLE_HEIGHT and Printer::IMG_DOUBLE_WIDTH flags.

◆ initialize()

Mike42\Escpos\Printer::initialize ( )

Initialize printer.

This resets formatting back to the defaults.

◆ intLowHigh()

static Mike42\Escpos\Printer::intLowHigh ( int  $input,
int  $length 
)
staticprotected

Generate two characters for a number: In lower and higher parts, or more parts as needed.

Parameters
int$inputInput number
int$lengthThe number of bytes to output (1 - 4).

◆ pdf417Code()

Mike42\Escpos\Printer::pdf417Code ( string  $content,
int  $width = 3,
int  $heightMultiplier = 3,
int  $dataColumnCount = 0,
float  $ec = 0.10,
int  $options = Printer::PDF417_STANDARD 
)

Print a two-dimensional data code using the PDF417 standard.

Parameters
string$contentText or numbers to store in the code
int$widthWidth of a module (pixel) in the printed code. Default is 3 dots.
int$heightMultiplierMultiplier for height of a module. Default is 3 times the width.
int$dataColumnCountNumber of data columns to use. 0 (default) is to auto-calculate. Smaller numbers will result in a narrower code, making larger pixel sizes possible. Larger numbers require smaller pixel sizes.
float$ecError correction ratio, from 0.01 to 4.00. Default is 0.10 (10%).
int$optionsStandard code Printer::PDF417_STANDARD with start/end bars, or truncated code Printer::PDF417_TRUNCATED with start bars only.
Exceptions
ExceptionIf this profile indicates that PDF417 code is not supported

◆ pulse()

Mike42\Escpos\Printer::pulse ( int  $pin = 0,
int  $on_ms = 120,
int  $off_ms = 240 
)

Generate a pulse, for opening a cash drawer if one is connected.

The default settings should open an Epson drawer.

Parameters
int$pin0 or 1, for pin 2 or pin 5 kick-out connector respectively.
int$on_mspulse ON time, in milliseconds.
int$off_mspulse OFF time, in milliseconds.

◆ qrCode()

Mike42\Escpos\Printer::qrCode ( string  $content,
int  $ec = Printer::QR_ECLEVEL_L,
int  $size = 3,
int  $model = Printer::QR_MODEL_2 
)

Print the given data as a QR code on the printer.

Parameters
string$contentThe content of the code. Numeric data will be more efficiently compacted.
int$ecError-correction level to use. One of Printer::QR_ECLEVEL_L (default), Printer::QR_ECLEVEL_M, Printer::QR_ECLEVEL_Q or Printer::QR_ECLEVEL_H. Higher error correction results in a less compact code.
int$sizePixel size to use. Must be 1-16 (default 3)
int$modelQR code model to use. Must be one of Printer::QR_MODEL_1, Printer::QR_MODEL_2 (default) or Printer::QR_MICRO (not supported by all printers).

◆ selectCharacterTable()

Mike42\Escpos\Printer::selectCharacterTable ( int  $table = 0)

Switch character table (code page) manually.

Used in conjunction with textRaw() to print special characters which can't be encoded automatically.

Parameters
int$tableThe table to select. Available code tables are model-specific.

◆ selectPrintMode()

Mike42\Escpos\Printer::selectPrintMode ( int  $mode = Printer::MODE_FONT_A)

Select print mode(s).

Several MODE_* constants can be OR'd together passed to this function's $mode argument. The valid modes are:

Parameters
int$modeThe mode to use. Default is Printer::MODE_FONT_A, with no special formatting. This has a similar effect to running initialize().

◆ selectUserDefinedCharacterSet()

Mike42\Escpos\Printer::selectUserDefinedCharacterSet (   $on = true)

Select user-defined character set.

Parameters
bool$onTrue to enable user-defined character set, false to use built-in characters sets.

◆ setBarcodeHeight()

Mike42\Escpos\Printer::setBarcodeHeight ( int  $height = 8)

Set barcode height.

Parameters
int$heightHeight in dots. If not specified, 8 will be used.

◆ setBarcodeTextPosition()

Mike42\Escpos\Printer::setBarcodeTextPosition ( int  $position = Printer::BARCODE_TEXT_NONE)

Set the position for the Human Readable Interpretation (HRI) of barcode characters.

Parameters
int$position,.Use Printer::BARCODE_TEXT_NONE to hide the text (default), or any combination of Printer::BARCODE_TEXT_ABOVE and Printer::BARCODE_TEXT_BELOW flags to display the text.

◆ setBarcodeWidth()

Mike42\Escpos\Printer::setBarcodeWidth ( int  $width = 3)

Set barcode bar width.

Parameters
int$widthBar width in dots. If not specified, 3 will be used. Values above 6 appear to have no effect.

◆ setColor()

Mike42\Escpos\Printer::setColor ( int  $color = Printer::COLOR_1)

Select print color on printers that support multiple colors.

Parameters
int$colorColor to use. Must be either Printer::COLOR_1 (default), or Printer::COLOR_2.

◆ setDoubleStrike()

Mike42\Escpos\Printer::setDoubleStrike ( bool  $on = true)

Turn double-strike mode on/off.

Parameters
boolean$ontrue for double strike, false for no double strike

◆ setEmphasis()

Mike42\Escpos\Printer::setEmphasis ( bool  $on = true)

Turn emphasized mode on/off.

Parameters
boolean$ontrue for emphasis, false for no emphasis

◆ setFont()

Mike42\Escpos\Printer::setFont ( int  $font = Printer::FONT_A)

Select font.

Most printers have two fonts (Fonts A and B), and some have a third (Font C).

Parameters
int$fontThe font to use. Must be either Printer::FONT_A, Printer::FONT_B, or Printer::FONT_C.

◆ setJustification()

Mike42\Escpos\Printer::setJustification ( int  $justification = Printer::JUSTIFY_LEFT)

Select justification.

Parameters
int$justificationOne of Printer::JUSTIFY_LEFT, Printer::JUSTIFY_CENTER, or Printer::JUSTIFY_RIGHT.

◆ setLineSpacing()

Mike42\Escpos\Printer::setLineSpacing ( int  $height = null)

Set the height of the line.

Some printers will allow you to overlap lines with a smaller line feed.

Parameters
int | null$heightThe height of each line, in dots. If not set, the printer will reset to its default line spacing.

◆ setPrintBuffer()

Mike42\Escpos\Printer::setPrintBuffer ( PrintBuffer  $buffer)

Attach a different print buffer to the printer.

Buffers are responsible for handling text output to the printer.

Parameters
PrintBuffer$bufferThe buffer to use.
Exceptions
InvalidArgumentExceptionWhere the buffer is already attached to a different printer.

◆ setPrintLeftMargin()

Mike42\Escpos\Printer::setPrintLeftMargin ( int  $margin = 0)

Set print area left margin.

Reset to default with Printer::initialize()

Parameters
int$marginThe left margin to set on to the print area, in dots.

◆ setPrintWidth()

Mike42\Escpos\Printer::setPrintWidth ( int  $width = 512)

Set print area width.

This can be used to add a right margin to the print area. Reset to default with Printer::initialize()

Parameters
int$widthThe width of the page print area, in dots.

◆ setReverseColors()

Mike42\Escpos\Printer::setReverseColors ( bool  $on = true)

Set black/white reverse mode on or off.

In this mode, text is printed white on a black background.

Parameters
boolean$onTrue to enable, false to disable.

◆ setTextSize()

Mike42\Escpos\Printer::setTextSize ( int  $widthMultiplier,
int  $heightMultiplier 
)

Set the size of text, as a multiple of the normal size.

Parameters
int$widthMultiplierMultiple of the regular height to use (range 1 - 8)
int$heightMultiplierMultiple of the regular height to use (range 1 - 8)

◆ setUnderline()

Mike42\Escpos\Printer::setUnderline ( int  $underline = Printer::UNDERLINE_SINGLE)

Set underline for printed text.

Parameters
int$underlineEither true/false, or one of Printer::UNDERLINE_NONE, Printer::UNDERLINE_SINGLE or Printer::UNDERLINE_DOUBLE. Defaults to Printer::UNDERLINE_SINGLE.

◆ setUpsideDown()

Mike42\Escpos\Printer::setUpsideDown ( bool  $on = true)

Print each line upside-down (180 degrees rotated).

Parameters
boolean$onTrue to enable, false to disable.

◆ text()

Mike42\Escpos\Printer::text ( string  $str)

Add text to the buffer.

Text should either be followed by a line-break, or feed() should be called after this to clear the print buffer.

Parameters
string$strText to print, as UTF-8

◆ textChinese()

Mike42\Escpos\Printer::textChinese ( string  $str = "")

Add Chinese text to the buffer.

This is a specific workaround for Zijang printers- The printer will be switched to a two-byte mode and sent GBK-encoded text.

Support for this will be merged into a print buffer.

Parameters
string$strText to print, as UTF-8

◆ textRaw()

Mike42\Escpos\Printer::textRaw ( string  $str = "")

Add text to the buffer without attempting to interpret chararacter codes.

Text should either be followed by a line-break, or feed() should be called after this to clear the print buffer.

Parameters
string$strText to print

◆ validateBoolean()

static Mike42\Escpos\Printer::validateBoolean ( bool  $test,
string  $source 
)
staticprotected

Throw an exception if the argument given is not a boolean.

Parameters
boolean$testthe input to test
string$sourcethe name of the function calling this

◆ validateFloat()

static Mike42\Escpos\Printer::validateFloat ( float  $test,
float  $min,
float  $max,
string  $source,
string  $argument = "Argument" 
)
staticprotected

Throw an exception if the argument given is not a float within the specified range.

Parameters
float$testthe input to test
float$minthe minimum allowable value (inclusive)
float$maxthe maximum allowable value (inclusive)
string$sourcethe name of the function calling this
string$argumentthe name of the invalid parameter

◆ validateInteger()

static Mike42\Escpos\Printer::validateInteger ( int  $test,
int  $min,
int  $max,
string  $source,
string  $argument = "Argument" 
)
staticprotected

Throw an exception if the argument given is not an integer within the specified range.

Parameters
int$testthe input to test
int$minthe minimum allowable value (inclusive)
int$maxthe maximum allowable value (inclusive)
string$sourcethe name of the function calling this
string$argumentthe name of the invalid parameter

◆ validateIntegerMulti()

static Mike42\Escpos\Printer::validateIntegerMulti ( int  $test,
array  $ranges,
string  $source,
string  $argument = "Argument" 
)
staticprotected

Throw an exception if the argument given is not an integer within one of the specified ranges.

Parameters
int$testthe input to test
array$rangesarray of two-item min/max ranges.
string$sourcethe name of the function calling this
string$sourcethe name of the function calling this
string$argumentthe name of the invalid parameter

◆ validateStringRegex()

static Mike42\Escpos\Printer::validateStringRegex ( string  $test,
string  $source,
string  $regex,
string  $argument = "Argument" 
)
staticprotected

Throw an exception if the argument doesn't match the given regex.

Parameters
string$testthe input to test
string$sourcethe name of the function calling this
string$regexvalid values for this attribute, as a regex
string$argumentthe name of the parameter being validated
Exceptions
InvalidArgumentExceptionWhere the argument is not valid

◆ wrapperSend2dCodeData()

Mike42\Escpos\Printer::wrapperSend2dCodeData ( string  $fn,
string  $cn,
string  $data = '',
string  $m = '' 
)
protected

Wrapper for GS ( k, to calculate and send correct data length.

Parameters
string$fnFunction to use
string$cnOutput code type. Affects available data
string$dataData to send.
string$mModifier/variant for function. Often '0' where used.
Exceptions
InvalidArgumentExceptionWhere the input lengths are bad.

◆ wrapperSendGraphicsData()

Mike42\Escpos\Printer::wrapperSendGraphicsData ( string  $m,
string  $fn,
string  $data = '' 
)
protected

Wrapper for GS ( L, to calculate and send correct data length.

Parameters
string$mModifier/variant for function. Usually '0'.
string$fnFunction number to use, as character.
string$dataData to send.
Exceptions
InvalidArgumentExceptionWhere the input lengths are bad.

The documentation for this class was generated from the following file: