setBarcodeHeight() public method

Set barcode height.
public setBarcodeHeight ( integer $height = 8 )
$height integer Height in dots. If not specified, 8 will be used.
Ejemplo n.º 1
0
    $printer->text("The quick brown fox jumps over the lazy dog\n");
}
$printer->setFont();
// Reset
$printer->cut();
/* Justification */
$justification = array(Printer::JUSTIFY_LEFT, Printer::JUSTIFY_CENTER, Printer::JUSTIFY_RIGHT);
for ($i = 0; $i < count($justification); $i++) {
    $printer->setJustification($justification[$i]);
    $printer->text("A man a plan a canal panama\n");
}
$printer->setJustification();
// Reset
$printer->cut();
/* Barcodes - see barcode.php for more detail */
$printer->setBarcodeHeight(80);
$printer->setBarcodeTextPosition(Printer::BARCODE_TEXT_BELOW);
$printer->barcode("9876");
$printer->feed();
$printer->cut();
/* Graphics - this demo will not work on some non-Epson printers */
try {
    $logo = EscposImage::load("resources/escpos-php.png", false);
    $imgModes = array(Printer::IMG_DEFAULT, Printer::IMG_DOUBLE_WIDTH, Printer::IMG_DOUBLE_HEIGHT, Printer::IMG_DOUBLE_WIDTH | Printer::IMG_DOUBLE_HEIGHT);
    foreach ($imgModes as $mode) {
        $printer->graphics($logo, $mode);
    }
} catch (Exception $e) {
    /* Images not supported on your PHP, or image file not found */
    $printer->text($e->getMessage() . "\n");
}
Ejemplo n.º 2
0
require __DIR__ . '/../autoload.php';
use Mike42\Escpos\Printer;
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
$connector = new FilePrintConnector("php://stdout");
$printer = new Printer($connector);
/* Height and width */
$printer->selectPrintMode(Printer::MODE_DOUBLE_HEIGHT | Printer::MODE_DOUBLE_WIDTH);
$printer->text("Height and bar width\n");
$printer->selectPrintMode();
$heights = array(1, 2, 4, 8, 16, 32);
$widths = array(1, 2, 3, 4, 5, 6, 7, 8);
$printer->text("Default look\n");
$printer->barcode("ABC", Printer::BARCODE_CODE39);
foreach ($heights as $height) {
    $printer->text("\nHeight {$height}\n");
    $printer->setBarcodeHeight($height);
    $printer->barcode("ABC", Printer::BARCODE_CODE39);
}
foreach ($widths as $width) {
    $printer->text("\nWidth {$width}\n");
    $printer->setBarcodeWidth($width);
    $printer->barcode("ABC", Printer::BARCODE_CODE39);
}
$printer->feed();
// Set to something sensible for the rest of the examples
$printer->setBarcodeHeight(40);
$printer->setBarcodeWidth(2);
/* Text position */
$printer->selectPrintMode(Printer::MODE_DOUBLE_HEIGHT | Printer::MODE_DOUBLE_WIDTH);
$printer->text("Text position\n");
$printer->selectPrintMode();
Ejemplo n.º 3
-4
<?php

require __DIR__ . '/../../autoload.php';
use Mike42\Escpos\Printer;
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
$a = "{A012323392982";
$b = "{B012323392982";
$c = "{C" . chr(01) . chr(23) . chr(23) . chr(39) . chr(29) . chr(82);
$connector = new FilePrintConnector("php://stdout");
$printer = new Printer($connector);
$printer->setJustification(Printer::JUSTIFY_CENTER);
$printer->setBarcodeHeight(48);
$printer->setBarcodeTextPosition(Printer::BARCODE_TEXT_BELOW);
foreach (array($a, $b, $c) as $item) {
    $printer->barcode($item, Printer::BARCODE_CODE128);
    $printer->feed(1);
}
$printer->cut();
$printer->close();