Closed aisuhua closed 8 years ago
I can use this code to print line. The below line is by typing Shift + - (in chinese imput method)
$printer->text("————————————————\n");
I want the line is not dotted but one line. Can i do this ? Think!
Hm, I've tried a few ideas on my TM-T20 USB. Maybe some will work for you.
<?php
/* Print example for horizontal lines on the Epson TM-T20 */
require __DIR__ . '/vendor/autoload.php';
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\Printer;
use Mike42\Escpos\EscposImage;
// Printer initialisation
$connector = new FilePrintConnector("/dev/usb/lp0");
$printer = new Printer($connector);
// Option 1. Underscores
$printer -> text("Option 1 is to simply use some underscores.\n" .
"These join seamlessly on some printers and\n" .
"sit at the bottom of the line:\n");
$printer -> text("______________________________________________\n");
$printer -> feed();
// Option 2. Box drawing characters
$printer -> text("The box characters from CP437 sit in the middle\n" .
"of the line, and work out of the box on most\n" .
"Epson printers. If your printer does not output\n" .
"CP437 by default then this wont work:\n");
$printer -> text("───────────────────────────────────────────────\n");
$printer -> text("Double-rule is also possible:\n");
$printer -> text("═══════════════════════════════════════════════\n");
$printer -> feed();
// Option 3. Underline
$printer -> text("You can even underline blank space\n");
$printer -> setUnderline(Printer::UNDERLINE_SINGLE);
$printer -> text(" \n");
$printer -> setUnderline(Printer::UNDERLINE_NONE);
$printer -> text("Or set a thicker underline\n");
$printer -> setUnderline(Printer::UNDERLINE_DOUBLE);
$printer -> text(" \n");
$printer -> setUnderline(Printer::UNDERLINE_NONE);
$printer -> feed();
// Option 4. This image was generated via imagemagick-
//
// convert -size 700x1 canvas:black line.png
//
$img = EscposImage::load('line.png');
$printer -> text("The finest lines can be drawn via\n" .
"graphics() on an Epson printer\n");
$printer -> graphics($img);
$printer -> text("On other printers, you may have to\n" .
"fall back on bitImage():\n");
$printer -> bitImage($img);
$printer -> text("And finally there is bitImageColumnFormat(),\n" .
"which is less efficient with vertical space.\n");
$printer -> bitImageColumnFormat($img);
// Rule image is from http://www.authorbrianjackson.com/gimpAndHTML/hrExample.html
//
// mogrify -resize 300x filigree.png
//
$img2 = EscposImage::load('filigree.png');
$printer -> text("The advantage of using images is that you can\n" .
"do something more complex if you like\n");
$printer -> setJustification(Printer::JUSTIFY_CENTER);
$printer -> graphics($img2);
$printer -> setJustification(Printer::JUSTIFY_LEFT);
$printer -> feed();
// Printer shutdown
$printer -> cut();
$printer -> close();
Thank you very much !
In last, I use bitImage
the print line. That is ok.
Any more, underline method is not convenient to adjust the line height. "Option 2. Box drawing characters" printed messy code (I use Star TSP700II)
Thank you very much ! In last, I use
bitImage
the print line. That is ok.Any more, underline method is not convenient to adjust the line height. "Option 2. Box drawing characters" printed messy code (I use Star TSP700II)
Hello friend, i see that you receipt can print Chinese, both of my printer wouldn't able to print Chinese use ecspos, can you please tell me how you can print Chinese on star printer?
Thanks!