Open gitsampath opened 4 years ago
Which model of printer you are using?
The cutter is generally located after the thermal head, so some spacing is often unavoidable. Eg. I do not know a way to avoid 2 lines of space before each print on a TM-T20II (corrected see below)
You usually expect your printer to feed the paper before a cut, so that the last line of text is just past the cutter when it slices the paper (eg. TM-T20 user guide contains a diagram on page 18).
The two tricks to know are:
cut()
are cut(Printer::CUT_FULL, 3)
, where 3 is the number of lines to feed before cutting. Many printers either ignore this parameter or enforce some minimum, but you may as well try using 2, 1, or 0 in this last argument.Posting again to correct to my last comment. I found #768, where I investigated this previously, and noted that ESC i
cuts with no line feed on my printer.
To send a command that isn't implemented in the library, write it directly to the connector, so in this case use $connector -> write("\x1bi");
(sends ESC i
) instead of $printer -> cut();
Using this code:
<?php
require __DIR__ . '/vendor/autoload.php';
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\CapabilityProfile;
use Mike42\Escpos\Printer;
$profile = CapabilityProfile::load("default");
$connector = new FilePrintConnector("php://stdout");
$printer = new Printer($connector, $profile);
for($i = 1; $i <= 3; $i++) {
$printer -> text("Line $i\n");
$connector -> write("\x1bi");
}
$printer -> text("Last line..\n");
$printer -> cut();
$printer -> close();
I printed this receipt on an Epson TM-T20II.
Provided that this command is available on your printer, you can probably get it to cut in the right spot with some trial and error.
Best of luck!
Hi Mike,
Thank you very much for your detailed explanation. I will check this and update the results.
Sam.
HI Mike
I have tried the above command on my Epson TM220 but its printing the same as you mentioned above . its cutting with no feed but its cutting first and then printing :) . As you said do some trial and error i did alot and wasted too much paper :) but still cant get the result pls assist Thanks.
$profile = CapabilityProfile::load("default");
$connector = new WP('EPSON DRYCLEAN');
$printer = new P($connector, $profile);
// $connector -> write("Hello\n\x1biWorld\n\x1bi");
$connector -> write("Line One");
$connector -> write("\x1bi");
$connector -> write("Line 2");
$connector -> write("\x1bi");
$connector -> write("Line 3");
$connector -> write("\x1bi");
// $printer -> pulse();
$printer -> cut();
$printer -> close();
Posting again to correct to my last comment. I found #768, where I investigated this previously, and noted that
ESC i
cuts with no line feed on my printer.To send a command that isn't implemented in the library, write it directly to the connector, so in this case use
$connector -> write("\x1bi");
(sendsESC i
) instead of$printer -> cut();
Using this code:
<?php require __DIR__ . '/vendor/autoload.php'; use Mike42\Escpos\PrintConnectors\FilePrintConnector; use Mike42\Escpos\CapabilityProfile; use Mike42\Escpos\Printer; $profile = CapabilityProfile::load("default"); $connector = new FilePrintConnector("php://stdout"); $printer = new Printer($connector, $profile); for($i = 1; $i <= 3; $i++) { $printer -> text("Line $i\n"); $connector -> write("\x1bi"); } $printer -> text("Last line..\n"); $printer -> cut(); $printer -> close();
I printed this receipt on an Epson TM-T20II.
Provided that this command is available on your printer, you can probably get it to cut in the right spot with some trial and error.
Best of luck!
thanks @mike42 , this is the solution to my problem. but I have another problem, when I print an example text
$printer -> text ("Visitor \ n");
then the result will be like this. Is it possible to add a little black rectangle at the top and bottom of the text to make it look like this?
Hi Mike,
I have an issue with my bill printing. As you can see from the attached image, the first bill printed after switch on the printer prints the bill header properly. But from second bill on wards the bill header prints in partial. This seems to be an issue with top margin of the page. I'm unable to fix this issue with escpos printer settings.
Please kindly help me to resolve this issue.
Thank you very much! Sam.
Following is the code which I use to print the erroneous bill.