1

I develop a web based label print application. So Now need to print this automatic without browser print preview. so how can I do this with php direct print...

Jahid Hasan
  • 29
  • 1
  • 2
  • Possible duplicate of [javascript print without print dialog box](https://stackoverflow.com/questions/4292373/javascript-print-without-print-dialog-box) – Jacob Mulquin Sep 24 '18 at 06:00
  • You should you Javascript for this action – Suman Sep 24 '18 at 06:32
  • Ok, have you tried anything to solve your problem? Can we see your code? Or do you expect others to code this for you? – brombeer Sep 24 '18 at 06:41
  • Current time I implement this with javascript print system with kiosk-printing. so now browser print preview show for just 1 second and take some time to start print. but my client want to direct silent print . I develop my application with php. So how is possible to print direct with php? I think you understand my problem Kerbholz suman Dey and mulquin – Jahid Hasan Sep 24 '18 at 09:33

4 Answers4

1

PHP is server side language can't access to client OS drivers (such as printer and etc)

, Also you can access & request to run PHP file scripts only from browser by domain or use cron job(cron is a Linux utility which schedules a command or script on your server to run automatically), you can't access to client system and use printer driver, but, for this you must use APP that installed on client OS,
or automatically run a js script, if client OS is linux: use cron job , if client OS is windows: use Cron Task or Scheduled Tasks

Sajad Mirzaei
  • 2,635
  • 1
  • 11
  • 13
1

you can print directly to any printer using PHP. I am using PHP for printing.

you can use mike42 escpos github plugin.

after download you need to make a connector for your printer. use this

after you can print. my sample for a shared printer and for a php file that is running by schedule task is:

require 'vendor/autoload.php';
use Mike42\Escpos\Printer;
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\CapabilityProfile;
use Mike42\Escpos\PrintConnectors\WindowsPrintConnector;


$connector = new WindowsPrintConnector("smb://computername/printername");
$printer = new Printer($connector);

$printer -> text("hello world");
$printer -> text("\n");
$printer -> text("\n");
$printer -> text("hello again");
$printer -> cut();
$printer -> close();
rezaSefiddashti
  • 134
  • 1
  • 9
0

you can use webclient for php refference link https://www.neodynamic.com/products/printing/raw-data/php/ i think this is what you want

Hasitha
  • 129
  • 1
  • 11
0

If you are using chrome, right click the shortcut icon, edit the target and add --kiosk-printing , it does the magic

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 04 '23 at 17:17