0

I have a TM-T88IV printer in my network. There are already 2 PCs connected to it and working fine. I added another PC to the network and added the printer on it with the 'generic/text only' driver. I used the following code to print to the printer but it does not print. It just gives me a blank page with no errors.

<?php
require 'escpos-php-development/autoload.php';
use Mike42\Escpos\Printer;
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
$connector = new FilePrintConnector("192.168.1.34",9100);
$printer = new Printer($connector);
try {
    $printer -> text("Hello World");
} finally {
    $printer -> close();
}
?> 

This is the basic file to print which does not work. Can anyone help?

Karan Gupta
  • 529
  • 2
  • 7
  • 21

1 Answers1

1

You should use network print connector

<?php
require 'escpos-php-development/autoload.php';
use Mike42\Escpos\Printer;
use Mike42\Escpos\PrintConnectors\NetworkPrintConnector;
$connector = new NetworkPrintConnector("192.168.1.34",9100);
$printer = new Printer($connector);
try {
    $printer -> text("Hello World");
} finally {
    $printer -> close();
}
?> 
Manikandan
  • 502
  • 1
  • 7
  • 17
  • I did the change and it gives me the error: Fatal error: Uncaught exception 'Exception' with message ' in E:\xampp\htdocs\myfiles\escpos-php-development\src\Mike42\Escpos\PrintConnectors\NetworkPrintConnector.php on line 38 ( ! ) Exception: Cannot initialise NetworkPrintConnector: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in E:\xampp\htdocs\myfiles\escpos-php-development\src\Mike42\Escpos\PrintConnectors\NetworkPrintConnector.php on line 38 – Karan Gupta Jul 10 '17 at 11:18