Print a page on local using php (javascript) without Windows print dialog box

狂风中的少年 提交于 2019-12-19 03:52:46

问题


I am developping an intranet for a shop. I need to print a receipt by clicking a submit button on php page. I do not want to see Windows print dialog box.

how can I do this. I need some advise

I will use Windows XP, I have full control of the system which this application will be running, Any application/plugin/exploits etc can be installed or used to help with removing the print dialog box.

Regards


回答1:


I do this with my shop order system written in PHP and it uses a print dialog via jquery. you can bypass the firefox print dialog by using the about:config page.

  • Open firefox and put about:config in the address bar and press enter (you will need to click the button that shows to say you know what you're doing)
  • Type print.always_print_silent in the filter box at the top If you have an entry already there and it is set to false just right click it and choose 'toggle' to set it to true. If there is no entry there already then follow on...
    • right click the screen and choose New->boolean
    • enter print.always_print_silent as the preference name when asked and press enter
    • set boolean value to true and press enter

That's it, you will no longer see the dialog box when you print. Beware though, it will try to print to the last printer you used when you had the dialog box open. If you ever need to change it then you will need to toggle the value for print.always_print_silent by following the above steps.




回答2:


You can't bypass the print dialog, advertisers would be printing out flyers to your printer if this was possible.




回答3:


Javascript can only trigger the print function with window.print(), but cannot change the way the browser works.




回答4:


You can't simply pass the pring dialog. I'm not aware of such functionality but could be possible using JAVA.




回答5:


Assuming you have the printer attached to the server, you can render the receipt/document to a PDF file, write it to a temporary directory and use the 'shell_exec' function to print it. The shell_exec function executes commands from the command line. Since Windows has something called a command line, it can be usefull.

Be aware that you need a program or batch file installed that can print a PDF from the command line. Such batch file can be found here.



来源:https://stackoverflow.com/questions/4077832/print-a-page-on-local-using-php-javascript-without-windows-print-dialog-box

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!