By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,424 Members | 1,351 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,424 IT Pros & Developers. It's quick & easy.

Simple way to write out a string on printer

P: n/a
Hi

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

than
Jesper.
Nov 15 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
In article <75**********************************@microsoft.co m>,
an*******@discussions.microsoft.com says...
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());
}
}
}
--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.