0

When I want to print 4 PNG files (100x100) via Mik42/ESCPOS. It printed each PNG file on each line. Is there any method to print all four PNG files in one line?

$printer -> setJustification(Printer::JUSTIFY_LEFT);
$printer -> graphics($HC1,false);
$printer -> graphics($HC1,false);
$printer -> graphics($HC1,false);
$printer -> graphics($HC1,false);
Ken
  • 55
  • 2
  • 13

2 Answers2

0

One of the following can be considered.

  1. Create one image data by arranging four image data in one horizontal line and print it.
  2. Set the page mode by combining the raw ESC/POS command data, repeat the print start position with the raw ESC/POS command data after the graphics print function of escpos-php, and finally the raw ESC/POS command, performs actual printing and page mode end.

Related ESC/POS commands:

ESC L Select Page mode
ESC W Set print area in Page mode
ESC T Select print direction in Page mode

GS $ Set absolute vertical print position in Page mode
ESC $ Set absolute print position
GS \ Set relative vertical print position in Page mode
ESC \ Set relative print position

FF (in Page mode) Print and return to Standard mode (in Page mode)

kunif
  • 4,060
  • 2
  • 10
  • 30
  • I have never used PHP. Therefore I cannot show you the coding. Would these articles be helpful? [Printing to POS printer from PHP](https://stackoverflow.com/q/25973046/9014308), [How to print raw ESC/POS commands from PHP directly to the client printer](https://www.neodynamic.com/articles/How-to-print-raw-ESC-POS-commands-from-PHP-directly-to-the-client-printer/) – kunif May 21 '20 at 09:07
0

With using imgagick saving it to a PNG file in web directory, then code it in PHP.

function appendImages($img1,$img2,$img3,$img4,$format) {

$im = new Imagick();

$im->addImage(new Imagick($_SERVER['DOCUMENT_ROOT'].'/images/'.$img1.'.jpg'));
$im->addImage(new Imagick($_SERVER['DOCUMENT_ROOT'].'/images/'.$img2.'.jpg'));
$im->addImage(new Imagick($_SERVER['DOCUMENT_ROOT'].'/images/'.$img3.'.jpg'));
$im->addImage(new Imagick($_SERVER['DOCUMENT_ROOT'].'/images/'.$img4.'.jpg'));

$im->resetIterator();
$combined = $im->appendImages(false);
$combined->setImageFormat($format);
$combined->writeImage($_SERVER['DOCUMENT_ROOT'].'/images/combined.png'); }
Ken
  • 55
  • 2
  • 13