Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am making a Web Part for a Point of sale site with .NET (visual studio 2012).

How can I print a text file from the site to a printer on the client side,

The printer will be a local printer attached to the client machine.
Posted

1 solution

You would have to use the client-side programming to print a web page document. If you want to use the JavaScript, then this would work for you,

JavaScript
// show the print dialog box
window.print();


The document in a web page form is already present on the client's system. Once this code would execute, it will display a print dialog to him, which he can then use to print the documents. You cannot force the machine to print, he will still have to press the "Print" button on his system, this would just facilitate him to see the dialog for printing the document.

MDN resources for window.print()[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900