public getSupportsQrCode ( ) : boolean | ||
return | boolean | True if QR code command is supported, false otherwise |
/** * Print the given data as a QR code on the printer. * * @param string $content The content of the code. Numeric data will be more efficiently compacted. * @param int $ec 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. * @param int $size Pixel size to use. Must be 1-16 (default 3) * @param int $model 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 function qrCode($content, $ec = Printer::QR_ECLEVEL_L, $size = 3, $model = Printer::QR_MODEL_2) { self::validateString($content, __FUNCTION__); self::validateInteger($ec, 0, 3, __FUNCTION__); self::validateInteger($size, 1, 16, __FUNCTION__); self::validateInteger($model, 1, 3, __FUNCTION__); if ($content == "") { return; } if (!$this->profile->getSupportsQrCode()) { // TODO use software rendering via phpqrcode instead throw new Exception("QR codes are not supported on your printer."); } $cn = '1'; // Code type for QR code // Select model: 1, 2 or micro. $this->wrapperSend2dCodeData(chr(65), $cn, chr(48 + $model) . chr(0)); // Set dot size. $this->wrapperSend2dCodeData(chr(67), $cn, chr($size)); // Set error correction level: L, M, Q, or H $this->wrapperSend2dCodeData(chr(69), $cn, chr(48 + $ec)); // Send content & print $this->wrapperSend2dCodeData(chr(80), $cn, $content, '0'); $this->wrapperSend2dCodeData(chr(81), $cn, '', '0'); }