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

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

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

P: n/a
In article <75********************************** m>,
an******* says...

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;

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);

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
Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.