How do I print to dot matrix printer on the client with a web application?

Asked

Viewed 1,067 times

3

I have an application made in C# MVC with a routine to print a plain text on the standard printer. The method was used RawPrinterHelper.SendStringToPrinter that is described in this article. Printing usually occurs when I run the application locally, but when I publish to the server, it lists the printer installed on the server and not the client.

How do I get the application to get the printer from the client and not from the server? If not possible, as I open then the printer dialog box by the application . NET C# MVC 4?

    public bool ImprimeConteudoDiretamenteNaImpressoraPadrao(string conteudo)
    {
       string nomeImpressoraPadrao = (new PrinterSettings()).PrinterName;
       return RawPrinterHelper.SendStringToPrinter(nomeImpressoraPadrao, conteudo);
    }
  • Take a look at this reply from soEN http://stackoverflow.com/questions/1501910/retrieving-clients-printer-collection-in-asp-net

  • Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?

2 answers

5

Client is client, server is server. For reasons that should be obvious it is not possible to access client resources through the server. The server can only send text and other data to the browser to decide what to do.

Even in the customer only the user can decide whether the printing will be carried out. A Javascript code can start the process and then the user can decide. You can’t do more than this.

window.print();

Web applications are not the solution for everything.

0

I managed to solve my problem as follows. I installed the matricial printer drives on the web server and set the name of the printer installed directly in the application, so it worked smoothly, the printer can be on the network or installed locally in the client.

string conteudo = "Teste impressão";
string _nomeImpressora = "EPSON FX-890 ESC/P";
RawPrinterHelper.SendStringToPrinter(_nomeImpressora, conteudo);
  • If this solved the problem because they gave -1 to the answer? I did not understand

  • @Marcelo the right answer to the question is not necessarily "good".

Browser other questions tagged

You are not signed in. Login or sign up in order to post.