PHP code example of mazinsw / escpos
1. Go to this page and download the library: Download mazinsw/escpos library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mazinsw / escpos example snippets
use Thermal\Printer;
use Thermal\Connection\Buffer;
use Thermal\Model;
$model = new Model('MP-4200 TH');
$connection = new Buffer();
$printer = new Printer($model, $connection);
$printer->setColumns(56);
$printer->write('Simple Text *** ');
$printer->writeln('Bold Text', Printer::STYLE_BOLD);
$printer->writeln('Double height', Printer::STYLE_DOUBLE_HEIGHT | Printer::STYLE_BOLD, Printer::ALIGN_CENTER);
$printer->qrcode('qrcode text');
$printer->feed(2);
$printer->buzzer();
$printer->cutter();
$printer->drawer(Printer::DRAWER_1);
echo $connection->getBuffer();
// redirect the output to your printer
// php example.php > COM1