Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

how to print to printer in c#

string s = text;
PrintDocument p = printDocument1;
p.PrinterSettings.PrinterName = printer;
if (print)
{
	p.PrintPage += delegate (object sender1, PrintPageEventArgs e1)
    {
    	e1.Graphics.DrawString(s, font, new SolidBrush(Color.Black), new RectangleF(0, 0, p.DefaultPageSettings.PrintableArea.Width, p.DefaultPageSettings.PrintableArea.Height));

    };
    try
   	{
    	p.Print();
    }
    catch (Exception ex)
     {
        throw new Exception("Exception Occured While Printing", ex);
      }
                
}
Source by nullorempty.org #
 
PREVIOUS NEXT
Tagged: #print #printer
ADD COMMENT
Topic
Name
4+8 =