Is it possible to have a link / button that directly prints the document through the website?

Is it possible to have a link / button that directly prints the document through the website?

+2


source to share


5 answers


The closest you can do is to use normal methods using javascript to display the print dialog. In the meantime, there is no need to know about it. ”



This limitation is built into the system and is designed to protect users like you from spammers who dream of turning your printer into another spam target for a fax machine. To get around this, you need to dive into the world of third party plugins.

+3


source


Assuming you don't need to specify a printable version on the page and just want to call the "Print" function in the browser, just:

<input type="button" value="Print" onclick="window.print();" />

      



or using the webcontrol button

<asp:button id="button1" runat="server" onclientclick="window.print(); return false;" text=Print" />

      

+2


source


You may need to write Applet, Flash, ActiveX components for this.

Note that:

The ActiveX component only works on Windows (mostly IE).
Applet / Flash can run on major OS like Windows / MAC / Linux

I suggest you go with the Applet, although the client has to install the JRE.

+1


source


Yes, just call javascript "window.print ()" on a link or button.

i.e.  

Edit: Looked at another comment about the need to print Office documents. Your only options here are to either open the document with your own application, or convert it to HTML or a PDF server.

As noted elsewhere, you can potentially inject an ActiveX object, but it causes all sorts of security issues and is unlikely to work in IE's default security settings and not on other web browsers.

If you are on an intranet, you can directly connect to the server printer directly, but other than that I am afraid that there is no real way to do this without significant caveats. I recommend just giving the user the download and letting them print it themselves.

0


source


I think you might need to read a complete document to be printed with some library that reads the entire document as text / html into a memory stream and writes to an output stream, finally calls window.print ();

0


source







All Articles