Simple way to write out a string on printer

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

What is the easiest way to write out a string to a printer

than
Jesper.
 
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());
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top