Printing from C# is very easy. Here is an example:
At top:
Code:
using System.Drawing.Printing;
Print Function:
Code:
public void Print()
{
PrintDocument tmpprndoc = new PrintDocument();
tmpprndoc.PrintPage += new PrintPageEventHandler(toPrinter);
// Load some variables
System.Windows.Forms.PrintDialog printDialog1 = new System.Windows.Forms.PrintDialog();
// Load the print dialog
if(printDialog1.ShowDialog() == DialogResult.OK)
{
// Change the default printer
tmpprndoc.PrinterSettings.PrinterName = printDialog1.PrinterSettings.PrinterName;
// Change orientation
tmpprndoc.PrinterSettings = printDialog1.PrinterSettings;
// Find our DPI Size (or pixels per inch)
GetDPISize();
// Print the document
tmpprndoc.Print();
}
}
What to print:
Code:
private void toPrinter(Object sender, PrintPageEventArgs e)
{
// Create our graphics object
Graphics g = e.Graphics;
// Set the color of our object
Brush br = new SolidBrush(Color.Black);
g.DrawString("Test Here", m_PrintFont, br, 5,5);