Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add multiple printers at once code? #789

Closed
ksoufiane opened this issue Sep 20, 2019 · 6 comments
Closed

add multiple printers at once code? #789

ksoufiane opened this issue Sep 20, 2019 · 6 comments

Comments

@ksoufiane
Copy link

Hello,

it's possible to use two printers to print the same copy via Ethernet (IP)?
example
Printer 1 $connector = new NetworkPrintConnector("192.168.1.10", 9100);
Printer 2 $connector2 = new NetworkPrintConnector("192.168.1.12", 9100);

Thank you i appreciate your help in advance.

@WilsonicX
Copy link

Is it possible to send a cut ticket to a two printers? for example for use in a restaurant: 1/2 ticket for the kitchen and the another 1/2 for the bar, splice the same ticket?

@ksoufiane ksoufiane changed the title add multiple printers at once code add multiple printers at once code!! Sep 23, 2019
@ksoufiane ksoufiane changed the title add multiple printers at once code!! add multiple printers at once code? Sep 23, 2019
@mike42
Copy link
Owner

mike42 commented Sep 24, 2019

There is no built-in for this, but it's easy enough to implement a PrintConnector which sends data to multiple printers. Do you think something like this would be useful in the library?

<?php
namespace Mike42\Escpos\PrintConnectors;

/**
 * Wrap multiple connectors up, to print to several printers at the same time.
 */
class MultiplePrintConnector implements PrintConnector {
    private $connectors;

    public function __construct(PrintConnector ...$connectors)
    {
        $this -> connectors = $connectors;
    }

    public function finalize()
    {
        foreach($this -> connectors as $connector) {
            $connector -> finalize();
        }
    }

    public function read($len)
    {
        // Cannot write
        return false;
    }

    public function write($data)
    {
        foreach($this -> connectors as $connector) {
            $connector -> write($data);
        }
    }

    public function __destruct()
    {
        // Do nothing
    }
}

And then something like-

<?php
require __DIR__ . '/vendor/autoload.php';
use Mike42\Escpos\PrintConnectors\NetworkPrintConnector;
use Mike42\Escpos\PrintConnectors\MultiplePrintConnector;
use Mike42\Escpos\Printer;

$kitchenPrinter = new NetworkPrintConnector("10.1.2.3", 9100);
$barPrinter = new NetworkPrintConnector("192.168.2.3", 9100);

$connector = new MultiplePrintConnector($kitchenPrinter, $barPrinter);
$printer = new Printer($connector);
$printer -> text("Hello World\n");
$printer -> cut();
$printer -> close();

Error handling would be really sketchy here, better make sure that the chef doesn't switch off the kitchen printer :)

@mike42 mike42 added the example label Sep 24, 2019
@ksoufiane
Copy link
Author

Yes, Multiple Printers feature is really useful.

Thank you for your help, i really appreciate your help in this matter.

@rehankausar
Copy link

i have also implement multiple printer and its working good with same data. is there any way to send categories wise receipt print to multiple printers at once.
for example:-
printer A has assigned category A and printer B has assigned category B and i want to print category A to Printer A and printer B to B at once.
apologies for bad English hope you can understand what i mean..

@WilsonicX
Copy link

i have also implement multiple printer and its working good with same data. is there any way to send categories wise receipt print to multiple printers at once.
for example:-
printer A has assigned category A and printer B has assigned category B and i want to print category A to Printer A and printer B to B at once.
apologies for bad English hope you can understand what i mean..

did you manage to send the separate categories of data?

I want to send category A to the Printer in the kitchen and category B to the Printer in the Bar, I think we have the same problem.

@shoaibeagledevs
Copy link

is it possible ?

how i can print simultaneously data on different printer for example

i have invoice which contain of 3 orders and i want to send each order data to separate kitchen printer .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants