toColumnFormat() public method

Output the image in column format.
public toColumnFormat ( boolean $doubleDensity = false ) : string[]
$doubleDensity boolean True for double density (24px) lines, false for single-density (8px) lines.
return string[] an array, one item per line of output. All lines will be of equal size.
Example #1
0
 /**
  * Print an image, using the older "bit image" command in column format.
  *
  * Should only be used if your printer does not support the graphics() or
  * bitImage() commands.
  *
  * @param EscposImage $img The image to print
  * @param int $size Size modifier for the image. Must be either `Printer::IMG_DEFAULT`
  *  (default), or any combination of the `Printer::IMG_DOUBLE_HEIGHT` and
  *  `Printer::IMG_DOUBLE_WIDTH` flags.
  */
 public function bitImageColumnFormat(EscposImage $img, $size = Printer::IMG_DEFAULT)
 {
     $highDensityVertical = !(($size & self::IMG_DOUBLE_HEIGHT) == Printer::IMG_DOUBLE_HEIGHT);
     $highDensityHorizontal = !(($size & self::IMG_DOUBLE_WIDTH) == Printer::IMG_DOUBLE_WIDTH);
     // Experimental column format printing
     // This feature is not yet complete and may produce unpredictable results.
     $this->setLineSpacing(16);
     // 16-dot line spacing. This is the correct value on both TM-T20 and TM-U220
     // Header and density code (0, 1, 32, 33) re-used for every line
     $densityCode = ($highDensityHorizontal ? 1 : 0) + ($highDensityVertical ? 32 : 0);
     $colFormatData = $img->toColumnFormat($highDensityVertical);
     $header = Printer::dataHeader(array($img->getWidth()), true);
     foreach ($colFormatData as $line) {
         // Print each line, double density etc for printing are set here also
         $this->connector->write(self::ESC . "*" . chr($densityCode) . $header . $line);
         $this->feed();
         // sleep(0.1); // Reduces the amount of trouble that a TM-U220 has keeping up with large images
     }
     $this->setLineSpacing();
     // Revert to default line spacing
 }