Change default printer c#

Asked

Viewed 623 times

3

I am working on a solution where I need to change the default printer for a label printer to print and return to the previous standard printer.

Would anyone have any solution to this?

1 answer

6


It worked that way, follow the code, thank you!

     using System.Drawing.Printing;
     using System.Runtime.InteropServices;

    private void trocarImpressora()
    {
        ArrayList impressoras = new ArrayList(); 
        int i = 0;

        PrintDocument pd = new PrintDocument();
        string impressoraPadraoOriginal = pd.PrinterSettings.PrinterName;
        myPrinters.SetDefaultPrinter("ZDesigner GC420t (EPL)");
        imprimir();
        myPrinters.SetDefaultPrinter(impressoraPadraoOriginal);

    }

  public static class myPrinters
    {
        [DllImport("winspool.drv", CharSet = CharSet.Auto, SetLastError = true)]
        public static extern bool SetDefaultPrinter(string Name);

    }

Browser other questions tagged

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