Print on client side with C# MVC automatically

Asked

Viewed 92 times

0

I need to automatically print a PDF file that is in a folder on the server, but the printing has to be in a specific printer on the CLIENT side.

if (!String.IsNullOrEmpty(caminho))
{
   string impressoraPadraoOriginal = new 
   System.Drawing.Printing.PrinterSettings().PrinterName;
    try
    {
     myPrinters.SetDefaultPrinter("Nome da impressora");

        Process process = new Process
        {
            StartInfo = new ProcessStartInfo
             {
                 CreateNoWindow = true,
                 Verb = "print",
                 FileName = caminho,
             },
        };
        process.Start();
    }
    catch (Exception)
    {
        throw;
    }
    finally
    {
        //Aguarda 5 segundos para alter a impresora padrão;
        System.Threading.Thread.Sleep(TimeSpan.FromSeconds(5));
        myPrinters.SetDefaultPrinter(impressoraPadraoOriginal);
    }
}

Local works properly, but when going to the server does not work.

  • 2

    Do you have any code? Post it we will help you!

  • There is no magic... it will have to be downloaded and displayed on the user screen to be printed... what there is is gambiarras with popup and iframe. But even so, the printer that will be used is chosen by the user at the time of printing

  • Why capture the exception for lance=la again? What do you think you get out of it? Actually there are losses.

No answers

Browser other questions tagged

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