Hi,
What is the easiest way to write out a string to a printer?
using System;
using System.Drawing;
using System.Drawing.Printing;
namespace PrintString
{
class Sample
{
private Font printFont;
private string printString;
[STAThread]
static void Main(string[] args)
{
Sample s = new Sample();
s.PrintAString("Hello, printer");
}
public void PrintAString(string data)
{
PrintDocument pd = new PrintDocument();
printFont = new Font("Tahoma", 12);
printString = data;
pd.PrintPage += new PrintPageEventHandler(PrintPage);
pd.Print();
}
private void PrintPage(object sender, PrintPageEventArgs e)
{
float xp = 10;
float yp = 20;
e.Graphics.DrawString(printString, printFont, Brushes.Black,
xp, yp, new StringFormat());
}
}
}