Метод | Описание | |
---|---|---|
__construct ( Mike42\Escpos\PrintConnectors\PrintConnector $connector, |
Construct a new print object | |
barcode ( string $content, integer $type = Printer::BARCODE_CODE39 ) | Print a barcode. | |
bitImage ( |
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. | |
bitImageColumnFormat ( |
Print an image, using the older "bit image" command in column format. | |
close ( ) | Close the underlying buffer. With some connectors, the job will not actually be sent to the printer until this is called. | |
cut ( integer $mode = Printer::CUT_FULL, integer $lines = 3 ) | Cut the paper. | |
feed ( integer $lines = 1 ) | Print and feed line / Print and feed n lines. | |
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 ( integer $lines = 1 ) | Print and reverse feed n lines. | |
getCharacterTable ( ) : number | ||
getPrintBuffer ( ) : Mike42\Escpos\PrintBuffers\PrintBuffer | ||
getPrintConnector ( ) : Mike42\Escpos\PrintConnectors\PrintConnector | ||
getPrinterCapabilityProfile ( ) : |
||
graphics ( |
Print an image to the printer. | |
initialize ( ) | Initialize printer. This resets formatting back to the defaults. | |
pdf417Code ( string $content, number $width = 3, number $heightMultiplier = 3, number $dataColumnCount, real $ec = 0.1, number $options = Printer::PDF417_STANDARD ) | Print a two-dimensional data code using the PDF417 standard. | |
pulse ( integer $pin, integer $on_ms = 120, integer $off_ms = 240 ) | Generate a pulse, for opening a cash drawer if one is connected. | |
qrCode ( string $content, integer $ec = Printer::QR_ECLEVEL_L, integer $size = 3, integer $model = Printer::QR_MODEL_2 ) | Print the given data as a QR code on the printer. | |
selectCharacterTable ( integer $table ) | Switch character table (code page) manually. Used in conjunction with textRaw() to print special characters which can't be encoded automatically. | |
selectPrintMode ( integer $mode = Printer::MODE_FONT_A ) | Select print mode(s). | |
setBarcodeHeight ( integer $height = 8 ) | Set barcode height. | |
setBarcodeTextPosition ( $position = Printer::BARCODE_TEXT_NONE ) | Set the position for the Human Readable Interpretation (HRI) of barcode characters. | |
setBarcodeWidth ( integer $width = 3 ) | Set barcode bar width. | |
setColor ( integer $color = Printer::COLOR_1 ) | Select print color on printers that support multiple colors. | |
setDoubleStrike ( boolean $on = true ) | Turn double-strike mode on/off. | |
setEmphasis ( boolean $on = true ) | Turn emphasized mode on/off. | |
setFont ( integer $font = Printer::FONT_A ) | Select font. Most printers have two fonts (Fonts A and B), and some have a third (Font C). | |
setJustification ( integer $justification = Printer::JUSTIFY_LEFT ) | Select justification. | |
setLineSpacing ( integer $height = null ) | Set the height of the line. | |
setPrintBuffer ( Mike42\Escpos\PrintBuffers\PrintBuffer $buffer ) | Attach a different print buffer to the printer. Buffers are responsible for handling text output to the printer. | |
setPrintLeftMargin ( integer $margin ) | Set print area left margin. Reset to default with Printer::initialize() | |
setPrintWidth ( integer $width = 512 ) | Set print area width. This can be used to add a right margin to the print area. | |
setReverseColors ( boolean $on = true ) | Set black/white reverse mode on or off. In this mode, text is printed white on a black background. | |
setTextSize ( integer $widthMultiplier, integer $heightMultiplier ) | Set the size of text, as a multiple of the normal size. | |
setUnderline ( integer $underline = Printer::UNDERLINE_SINGLE ) | Set underline for printed text. | |
text ( string $str = "" ) | Add text to the buffer. | |
textChinese ( string $str = "" ) | Add Chinese text to the buffer. This is a specific workaround for the common Zijang printer- The printer will be switched to a two-byte mode and sent GBK-encoded text. | |
textRaw ( string $str = "" ) | Add text to the buffer without attempting to interpret chararacter codes. |
Метод | Описание | |
---|---|---|
validateBoolean ( boolean $test, string $source ) | Throw an exception if the argument given is not a boolean | |
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 | |
validateInteger ( integer $test, integer $min, integer $max, string $source, string $argument = "Argument" ) | Throw an exception if the argument given is not an integer within the specified range | |
validateIntegerMulti ( integer $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 | |
validateString ( string $test, string $source, string $argument = "Argument" ) | Throw an exception if the argument given can't be cast to a string | |
validateStringRegex ( string $test, string $source, string $regex, string $argument = "Argument" ) | Throw an exception if the argument doesn't match the given regex. |
Метод | Описание | |
---|---|---|
dataHeader ( array $inputs, boolean $long = true ) : string | Convert widths and heights to characters. Used before sending graphics to set the size. | |
intLowHigh ( integer $input, integer $length ) | Generate two characters for a number: In lower and higher parts, or more parts as needed. | |
wrapperSend2dCodeData ( string $fn, string $cn, string $data = '', string $m = '' ) | Wrapper for GS ( k, to calculate and send correct data length. | |
wrapperSendGraphicsData ( string $m, string $fn, string $data = '' ) | Wrapper for GS ( L, to calculate and send correct data length. |
public __construct ( Mike42\Escpos\PrintConnectors\PrintConnector $connector, |
||
$connector | Mike42\Escpos\PrintConnectors\PrintConnector | The PrintConnector to send data to. If not set, output is sent to standard output. |
$profile | Supported features of this printer. If not set, the "default" CapabilityProfile will be used, which is suitable for Epson printers. |
public barcode ( string $content, integer $type = Printer::BARCODE_CODE39 ) | ||
$content | string | The information to encode. |
$type | integer | The 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. |
public bitImageColumnFormat ( |
||
$img | The image to print | |
$size | integer | Size 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. |
public close ( ) |
public feedForm ( ) |
public feedReverse ( integer $lines = 1 ) | ||
$lines | integer | number of lines to feed. If not specified, 1 line will be fed. |
public getPrintBuffer ( ) : Mike42\Escpos\PrintBuffers\PrintBuffer | ||
Результат | Mike42\Escpos\PrintBuffers\PrintBuffer |
public getPrintConnector ( ) : Mike42\Escpos\PrintConnectors\PrintConnector | ||
Результат | Mike42\Escpos\PrintConnectors\PrintConnector |
public getPrinterCapabilityProfile ( ) : |
||
Результат |
public initialize ( ) |
public pdf417Code ( string $content, number $width = 3, number $heightMultiplier = 3, number $dataColumnCount, real $ec = 0.1, number $options = Printer::PDF417_STANDARD ) | ||
$content | string | Text or numbers to store in the code |
$width | number | Width of a module (pixel) in the printed code. Default is 3 dots. |
$heightMultiplier | number | Multiplier for height of a module. Default is 3 times the width. |
$dataColumnCount | number | Number 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. |
$ec | real | Error correction ratio, from 0.01 to 4.00. Default is 0.10 (10%). |
$options | number | Standard code Printer::PDF417_STANDARD with start/end bars, or truncated code Printer::PDF417_TRUNCATED with start bars only. |
public qrCode ( string $content, integer $ec = Printer::QR_ECLEVEL_L, integer $size = 3, integer $model = Printer::QR_MODEL_2 ) | ||
$content | string | The content of the code. Numeric data will be more efficiently compacted. |
$ec | integer | Error-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. |
$size | integer | Pixel size to use. Must be 1-16 (default 3) |
$model | integer | QR 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). |
public selectCharacterTable ( integer $table ) | ||
$table | integer | The table to select. Available code tables are model-specific. |
public selectPrintMode ( integer $mode = Printer::MODE_FONT_A ) | ||
$mode | integer | The mode to use. Default is Printer::MODE_FONT_A, with no special formatting. This has a similar effect to running initialize(). |
public setBarcodeHeight ( integer $height = 8 ) | ||
$height | integer | Height in dots. If not specified, 8 will be used. |
public setBarcodeTextPosition ( $position = Printer::BARCODE_TEXT_NONE ) |
public setBarcodeWidth ( integer $width = 3 ) | ||
$width | integer | Bar width in dots. If not specified, 3 will be used. Values above 6 appear to have no effect. |
public setDoubleStrike ( boolean $on = true ) | ||
$on | boolean | true for double strike, false for no double strike |
public setEmphasis ( boolean $on = true ) | ||
$on | boolean |
public setJustification ( integer $justification = Printer::JUSTIFY_LEFT ) | ||
$justification | integer | One of Printer::JUSTIFY_LEFT, Printer::JUSTIFY_CENTER, or Printer::JUSTIFY_RIGHT. |
public setLineSpacing ( integer $height = null ) | ||
$height | integer | The height of each line, in dots. If not set, the printer will reset to its default line spacing. |
public setPrintBuffer ( Mike42\Escpos\PrintBuffers\PrintBuffer $buffer ) | ||
$buffer | Mike42\Escpos\PrintBuffers\PrintBuffer | The buffer to use. |
public setPrintLeftMargin ( integer $margin ) | ||
$margin | integer | The left margin to set on to the print area, in dots. |
public setPrintWidth ( integer $width = 512 ) | ||
$width | integer | The width of the page print area, in dots. |
public setReverseColors ( boolean $on = true ) | ||
$on | boolean | True to enable, false to disable. |
public setTextSize ( integer $widthMultiplier, integer $heightMultiplier ) | ||
$widthMultiplier | integer | Multiple of the regular height to use (range 1 - 8) |
$heightMultiplier | integer | Multiple of the regular height to use (range 1 - 8) |
public setUnderline ( integer $underline = Printer::UNDERLINE_SINGLE ) | ||
$underline | integer | Either true/false, or one of Printer::UNDERLINE_NONE, Printer::UNDERLINE_SINGLE or Printer::UNDERLINE_DOUBLE. Defaults to Printer::UNDERLINE_SINGLE. |
public textChinese ( string $str = "" ) | ||
$str | string | Text to print, as UTF-8 |
protected static validateBoolean ( boolean $test, string $source ) | ||
$test | boolean | the input to test |
$source | string | the name of the function calling this |
protected static validateFloat ( float $test, float $min, float $max, string $source, string $argument = "Argument" ) | ||
$test | float | the input to test |
$min | float | the minimum allowable value (inclusive) |
$max | float | the maximum allowable value (inclusive) |
$source | string | the name of the function calling this |
$argument | string | the name of the invalid parameter |
protected static validateInteger ( integer $test, integer $min, integer $max, string $source, string $argument = "Argument" ) | ||
$test | integer | the input to test |
$min | integer | the minimum allowable value (inclusive) |
$max | integer | the maximum allowable value (inclusive) |
$source | string | the name of the function calling this |
$argument | string | the name of the invalid parameter |
protected static validateIntegerMulti ( integer $test, array $ranges, string $source, string $argument = "Argument" ) | ||
$test | integer | the input to test |
$ranges | array | array of two-item min/max ranges. |
$source | string | the name of the function calling this |
$argument | string | the name of the invalid parameter |
protected static validateStringRegex ( string $test, string $source, string $regex, string $argument = "Argument" ) | ||
$test | string | the input to test |
$source | string | the name of the function calling this |
$regex | string | valid values for this attribute, as a regex |
$argument | string | the name of the parameter being validated |