0

From This link(Printing to POS printer from PHP) i started I have use php sample code. my question is my printer is set to default then why i have to connect to printer. anyway i am getting error on connecting printer. as my printer name is in fig1 and to access printer i have to type \Sah-it\ARP-808K in run as shown in fig2. i have tried:

1.

$connector = new FilePrintConnector("\\Sah-it\ARP-808K");
$printer = new Printer($connector);

2.

$profile = CapabilityProfile::load("simple");
$connector = new WindowsPrintConnector("smb://Sah-it/ARP-808Kr");
$printer = new Printer($connector, $profile);

3.

$connector = new NetworkPrintConnector("\\Sah-it\ARP-808K");
$printer = new Printer($connector);

all gives me connection error. Kindly help me to connect printer. Thanks

Fig1:

enter image description here

Fig2:

enter image description here

Community
  • 1
  • 1
Raza Saleem
  • 185
  • 3
  • 16

1 Answers1

0

I've personally not used ESC/POS Print Driver for PHP library but the documentation does state the use in a fairly detailed way. Judging by your images, you have a printer shared from a server called \\Sah-it\ARP-808K. To connect (guessing the printer is an Epson), it's advised you do the following:

    use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;
    use Mike42\Escpos\CapabilityProfile;
    $profile = CapabilityProfile::load("simple");
    $connector = new WindowsPrintConnector("smb://Sah-it/ARP-808K");
    $printer = new Printer($connector, $profile);

Note: Suitable for Epson TM-series printers so check documentation to ensure your printer is supported

If your having issues with the above via hostname, then check your PHP servers DNS configuration as it may not be able to resolve Sah-it. In this instance I would suggest trying to connect via IP to the printer (if networked) or to your print-server's IP using the following:

use Mike42\Escpos\PrintConnectors\NetworkPrintConnector;
use Mike42\Escpos\Printer;
$connector = new NetworkPrintConnector("10.x.x.x", 9100); //Printer/Server IP
$printer = new Printer($connector);
try {
    // ... Print stuff
} finally {
    $printer -> close();
}

if you have further issues then add your printer make and model, confirm your Webserver can resolve \\Sah-it and add any relevant errors which may help.

Kitson88
  • 2,889
  • 5
  • 22
  • 37
  • Geting these Errors: 1. Warning: copy(\\Sah-it\ARP-808K): failed to open stream: Permission denied in C:\wamp\www\p\vendor\mike42\escpos-php\src\Mike42\Escpos\PrintConnectors\WindowsPrintConnector.php on line 372 2. Fatal error: Uncaught exception 'Exception' with message 'Failed to copy file to printer' in C:\wamp\www\p\vendor\mike42\escpos-php\src\Mike42\Escpos\PrintConnectors\WindowsPrintConnector.php on line 291 3. Exception: Failed to copy file to printer in C:\wamp\www\p\vendor\mike42\escpos-php\src\Mike42\Escpos\PrintConnectors\WindowsPrintConnector.php on line 291 – Raza Saleem Dec 31 '16 at 14:21
  • Check this Issue on Github: https://github.com/mike42/escpos-php/issues/67 – Kitson88 Dec 31 '16 at 14:22
  • It goes through debugging the printer connection. Also try via IP and Port as it seems this is definitely a connection issue from your WAMP server to Printer. – Kitson88 Dec 31 '16 at 14:23
  • Someone also mentioned changing the permissions on the printer to `Full Control` for the NETWORK account. – Kitson88 Dec 31 '16 at 14:27
  • Thanks I have Tried this smb://bob:secret@computer/workgroup/printer and its working – Raza Saleem Dec 31 '16 at 15:27
  • No worries and glad it's sorted. – Kitson88 Dec 31 '16 at 15:42
  • there? i am facing problem as i am using WindowsPrintConnector on live server i am geting error no printer found: "Failed to print. Command "net use "\\Sah-it\ARP-808K" "/user:USMAN" "*****"" failed with exit code 2: System error 53 has occurred. The network path was not found." as i am running same pc its working locally perfect – Raza Saleem Jan 08 '17 at 06:43
  • Can you ping `sah-it` from your server using command prompt? Does nslookup resolve to the correct IP address from your server using command prompt? Have you tried using up address direct? – Kitson88 Jan 08 '17 at 10:06
  • Its server of godady how can I ping? – Raza Saleem Jan 08 '17 at 17:56
  • If your server is hosted In Datacenter and your printer is only accessible on your LAN then how did you expect for it to be able to communicate using just Sah-it? Your going to need to either make this printer accessible externally (huge security risks) or VPN into your LAN from your Dedicated Server. – Kitson88 Jan 08 '17 at 18:33