How to make a website print

This will sound like an odd request, but ... I have a web application that is configured to collect data and store it in the database at regular intervals. The application is designed to basically remain open all the time, and the screen displays what has recently been added to the database (using ajax to check the database and refresh the page when there is something new). I also need to create a listing when something is added to the database. I currently have a print button that causes the print dialog to pop up and use a different stylesheet for the "print view", but the user still needs to click the print button and then click print in the dialog that appears. Is there a way to fully automate the process ,so that the site prints the page on the default printer and bypasses the print button and the dialog screen that appears?

Edit: I know what window.print () can do; to open the print dialog ... I asked if I could actually make a page from a printer without any human input. And, based on the messages, it seems that this cannot be done only with a web browser.

+3
source share
5 answers

You can write a standalone application that has a web browser control and let it print for you. There is no way to do this in a normal browser, though ... think about the consequences of this.

+10
source

(, , ), ( javascript),

( javascript )

<script language="Javascript1.2">
  <!--
  function printpage() {
  window.print();
  }
  //-->
</script>
+3

JS, , window.print(), ajax-. .

0

, - .

, , , ajax -, (wkhtmltopdf ), - ( Linux, OSX, Windows Server) ( ) , . OSX Automator. Linux bash script, X ( cron) lpr . Windows... , , , , Windows "folder-as-print-queue". , .

0
source

Source: https://habr.com/ru/post/1773695/


All Articles