最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin3浏览0评论

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

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

Share Improve this question edited Nov 2, 2010 at 14:26 eMRe asked Nov 2, 2010 at 12:57 eMReeMRe 3,2476 gold badges37 silver badges51 bronze badges 2
  • Due to Javascript sandboxing, I would not be surprised if what you are asking is impossible. – Hammerite Commented Nov 2, 2010 at 12:58
  • 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. – eMRe Commented Nov 2, 2010 at 14:14
Add a comment  | 

5 Answers 5

Reset to default 9

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.

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

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

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

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.

发布评论

评论列表(0)

  1. 暂无评论