getSupportsPdf417Code() public method

public getSupportsPdf417Code ( ) : boolean
return boolean True if PDF417 code command is supported, false otherwise
示例#1
0
 /**
  * Print a two-dimensional data code using the PDF417 standard.
  *
  * @param string $content Text or numbers to store in the code
  * @param number $width Width of a module (pixel) in the printed code.
  *  Default is 3 dots.
  * @param number $heightMultiplier Multiplier for height of a module.
  *  Default is 3 times the width.
  * @param number $dataColumnCount 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.
  * @param real $ec Error correction ratio, from 0.01 to 4.00. Default is 0.10 (10%).
  * @param number $options Standard code Printer::PDF417_STANDARD with
  *  start/end bars, or truncated code Printer::PDF417_TRUNCATED with start bars only.
  * @throws Exception If this profile indicates that PDF417 code is not supported
  */
 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');
 }