Click here to Skip to main content
15,885,014 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I am currently working on asp.net c# Project on POS(Point Of Sale). i am using javascript function on page load but it populate print dialogue box in google chrome. This is my page load javascript function.
JavaScript
<script type="text/javascript">
        window.onload = function () {
            window.print();
           
        }

</script>

I dont want this google chrome print dialog box. how can in print invoice directly on button click...I am stuck at this point. I try my best but did not find. Anyone help regarding this problem. Please help me out

What I have tried:

i used javascipt function. i want some c# function which directly print the invoice.
Posted
Updated 26-Jul-16 22:15pm

This is a frequently asked question, please do basic research such as a google search before you ask a question.

The answer is that you can't. If the client wants to print something then they will. Would you want websites forcing things to your printer without your intervention?
 
Share this answer
 
The C# code runs on the server. It cannot access printers connected to the client. Unless you can connect the printer directly to the web server, and run your application pool as a user which has the printer configured, that's not going to work.

Code running on the client cannot print anything without the user's consent. If it could, that would be a major security vulnerability. Imagine what would happen if you visited a malicious site, and your company printer suddenly started churning out page after page of porn...
 
Share this answer
 
Comments
Jalal Akram Sufi 26-Jul-16 2:06am    
but i am deploying the POS offline on client system.
Richard Deeming 26-Jul-16 7:33am    
Then you'll need to connect the printer to the system that's hosting the site, run the site as a user which has the printer configured, and print from the server-side code.

How you do that depends on what you're trying to print.
Sometimes tricks comes with a cost. If you can afford your application to be a single browser supported i.e. Google Chrome than you can use Silent/Kiosk Printing feature of Chrome.

A bit detailed article can be found Here

Or you can search on Google for further information.


Hope it helps. :)
 
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