Mike42\Escpos\Printer::pdf417Code PHP Method

pdf417Code() public method

Print a two-dimensional data code using the PDF417 standard.
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 function pdf417Code($content, $width = 3, $heightMultiplier = 3, $dataColumnCount = 0, $ec = 0.1, $options = Printer::PDF417_STANDARD)
    {
        self::validateString($content, __FUNCTION__, 'content');
        self::validateInteger($width, 2, 8, __FUNCTION__, 'width');
        self::validateInteger($heightMultiplier, 2, 8, __FUNCTION__, 'heightMultiplier');
        self::validateInteger($dataColumnCount, 0, 30, __FUNCTION__, 'dataColumnCount');
        self::validateFloat($ec, 0.01, 4.0, __FUNCTION__, 'ec');
        self::validateInteger($options, 0, 1, __FUNCTION__, 'options');
        if ($content == "") {
            return;
        }
        if (!$this->profile->getSupportsPdf417Code()) {
            // TODO use software rendering via a library instead
            throw new Exception("PDF417 codes are not supported on your printer.");
        }
        $cn = '0';
        // Code type for pdf417 code
        // Select model: standard or truncated
        $this->wrapperSend2dCodeData(chr(70), $cn, chr($options));
        // Column count
        $this->wrapperSend2dCodeData(chr(65), $cn, chr($dataColumnCount));
        // Set dot sizes
        $this->wrapperSend2dCodeData(chr(67), $cn, chr($width));
        $this->wrapperSend2dCodeData(chr(68), $cn, chr($heightMultiplier));
        // Set error correction ratio: 1% to 400%
        $ec_int = (int) ceil(floatval($ec) * 10);
        $this->wrapperSend2dCodeData(chr(69), $cn, chr($ec_int), '1');
        // Send content & print
        $this->wrapperSend2dCodeData(chr(80), $cn, $content, '0');
        $this->wrapperSend2dCodeData(chr(81), $cn, '', '0');
    }