0

I am about to start a small POS project. That is not online application. That will be running on LAN network. I decided to use ASP.NET MVC in C# for that application instead of windows forms because my client wants better UI and he wants it.

But my problem is I have to provide a feature in my application that print out the invoice directly from printer machine. In windows forms, that can be done easily(but I am not experienced). So I have to start my project soon. I found a lot of articles online , but they are just explaining how to render of export as pdf file . They do not show the printing step.

Can this be done with ASP.NET, printing invoice? If not, I have to go with another one (windows forms).

halfer
  • 19,824
  • 17
  • 99
  • 186
Wai Yan Hein
  • 13,651
  • 35
  • 180
  • 372

2 Answers2

2

While dealing with POS, you need to be more specific to the printer you are going to use. I got a chance to work on a POS project in past and struggled a lot with printers as thermal printer has different resolution than dot matrix.

As you are creating a web application, your only option is to play with Javascript at client side to print from browser controls. You may find an SMS printer handy where you can send an SMS to the printer and get it printed. It will give you more control and the printer can be placed anywhere remotely.

DevGuru
  • 156
  • 3
  • So please can I have perfect link for integration SMS printer with asp.net mvc ? – Wai Yan Hein Dec 28 '15 at 04:33
  • Using Javascript: http://stackoverflow.com/questions/2255291/print-the-contents-of-a-div and using GSM (SMS) Printer: As an example, you can find printers here. http://www.gsm-printer.com/category/products/498 GSM printer prints an SMS sent from a phone or from online system. The best approach is to use a 3rd party solution like Twilio where you integrate with their API and Twilio system will send the SMS forward. http://stackoverflow.com/questions/5467905/sending-sms-from-asp-net-website – DevGuru Dec 28 '15 at 12:24
  • Thank you. But can sms be sent over a lan in GSM without charging any bill ? How to achieve it ? – Wai Yan Hein Dec 29 '15 at 04:55
  • No, you can't send over LAN. If you have a small project with minimal future growth then use Javascript. Format the invoice in a div and send it to printer. The output formatting will vary on different printer but can be adjusted with little play. – DevGuru Jan 01 '16 at 15:11
0

So what I can understand is that you want invoice generated by your web application and that can be printed. To begin with, you will need to look into to things:

  1. CSS media queries for print (http://www.w3schools.com/css/css3_mediaqueries.asp) and
  2. JavaScript functions for print ( window.print();)

CSS for print will decide what your presentation will be for printer.

If you need to create PDF of the invoice then there are libraries like Rotativa https://github.com/webgio/Rotativa that will work with MVC to generate PDF's. Once you have pdf, it can be printed easily.

KrishnaDhungana
  • 2,604
  • 4
  • 25
  • 37
  • 1
    @downvoter .. what is wrong in the answer?? It can be the starting point. – KrishnaDhungana Dec 22 '15 at 05:37
  • Not sure why some has downvoted this.. Surely this is a starting point.. Also question is not very clear – Satyaki Chatterjee Dec 22 '15 at 06:46
  • I want to generate it with C#. When I click a button, invoice must be generated. Not using built in browser print feature. – Wai Yan Hein Dec 22 '15 at 13:33
  • I am not crating PDF file as well. I want to print invoice with lowest user interaction like in windows form. – Wai Yan Hein Dec 22 '15 at 13:35
  • @Waiyan I have used Rotativa before and it works fine as free to use. The design is controlled via HTML and CSS so you will need to research on the PDF document. Check https://github.com/webgio/Rotativa or alternatively you could use other libraries like iTextSharp – KrishnaDhungana Dec 22 '15 at 23:04
  • @SatyakiChatterjee thanks mate – KrishnaDhungana Dec 22 '15 at 23:05
  • Please . I already viewd github.com/webgio/Rotativa . But for asp mvc that only explains how to generate pdf. What I want it I want to print it out directly when user click a button on UI. So please how can I achieve it ? Is there a way to print out a pdf file in asp.net mvc ? – Wai Yan Hein Dec 28 '15 at 04:31