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...
-
Possible duplicate of javascript print without print dialog boxJacob Mulquin– Jacob Mulquin2018-09-24 06:00:54 +00:00Commented Sep 24, 2018 at 6:00
-
You should you Javascript for this actionSuman– Suman2018-09-24 06:32:43 +00:00Commented Sep 24, 2018 at 6: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?user8034901– user80349012018-09-24 06:41:06 +00:00Commented Sep 24, 2018 at 6: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 mulquinJahid Hasan– Jahid Hasan2018-09-24 09:33:27 +00:00Commented Sep 24, 2018 at 9:33
4 Answers
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
Comments
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();
Comments
you can use webclient for php refference link https://www.neodynamic.com/products/printing/raw-data/php/ i think this is what you want
Comments
If you are using chrome, right click the shortcut icon, edit the target and add --kiosk-printing , it does the magic