23 July 2016

Print File to Printer Different ways C#

Easy way to print file:

            PrintDocument pd = new PrintDocument();
            pd.PrinterSettings.PrinterName = "Hp Printer";
            pd.DocumentName = "Bar.txt";
            pd.Print();
            MessageBox.Show("Printer: Hp Printer" + " " + "\nFile: Bar.txt");

Another way to Print File:

         private void button1_Click(object sender, EventArgs e)
        {
            System.IO.StreamReader filetoprint;
              filetoprint = new System.IO.StreamReader(@"D:\\m.txt");
              printDocument1.Print();
              filetoprint.Close();
        }

Another way to Print File:

        var pi=new ProcessStartInfo("C:\file.docx");
        pi.UseShellExecute = true;
        pi.Verb = "print";
        var process =  System.Diagnostics.Process.Start(pi);


Suggest Blog for daily News in Tamil: tamizhnewz.blogspot.in 

No comments:

Post a Comment