473,320 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Simple way to write out a string on printer

Hi

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

than
Jesper.
Nov 15 '05 #1
1 1951
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Uros | last post by:
Does anybody know how to write data directly to the LPT port from MSAccess. Now I use "Open PrtPort For Append Access Write As IntFilenum" then "Print $IntFilenum, ..........." but doesn't work...
2
by: MLH | last post by:
I would like to allow users to set, as an application default, a specific printer to send reports to. I don't know how to bring up a list of valid print devices in A97, nor do I know how to...
5
by: Tim | last post by:
Hi Guys, I want to write a string to a multiline textbox. Below is the code. Works great except the carriage returns are displayed as squares. What do I need to do to have the text displayed...
4
by: Noozer | last post by:
Can someone provide a simple example of how to print using VB.Net??? Basically just looking for a "HELLO WORLD" example to the printer. I'll worry about formatting, etc. later on. Right now I...
6
by: Chris Dunaway | last post by:
The method for printing documents in .Net can be confusing, especially for newer users. I would like to create a way to simplify this process. My idea would be implemented using a PrintDocument...
23
by: Marco | last post by:
Could anyone please tell me why the program has the following error? I copy the program from http://www.beyondlogic.org/parlcd/parlcd.htm ...
3
by: ctbfalcon | last post by:
So I have a progress bar that I would like to be diplayed as the program is working on adding a network printer. I want to do this because while the program is "thinking" the user is not sure if...
0
by: developer200701 | last post by:
The following code (which is distilled down from a larger application) worked for several years previously. Now, the instant you click on the print icon within the print preview window the...
8
by: Mike Silva | last post by:
Hello all, I'm a longtime programmer (embedded with a smattering of desktop stuff as well) who knows very little about web programming. Right now I am developing the prototype of a multi-user...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.