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

printing on the right side of paper

P: n/a
Friends,

I'm (a bit) dissapointed about the printing possibilities in c#. It could
also be lack of knowedge.

I would like to align a text on the right side of the paper when printing.

For example
tekst = DateTime.Today.Date.ToString("dd-MM-yyyy");
// asign content to the variable tekst
SizeF stringSize= ev.Graphics.MeasureString(tekst, printFont);
// measure the length of the tekst ... in what??
xPos = (float) ev.MarginBounds.Right - stringSize;
// to aligh it on thr right side of the paper
ev.Graphics.DrawString (tekst, printFont, Brushes.Black, xPos, yPos, new
StringFormat());

I would like to print tekst now but I have problems with the typing.

I tried all kinds of things but there must be some easy way of doing this.
Who can help me with this..

and who knows a bunch of nice printing functions. I dont like the way C#
handles the printer control.

regards
Gerrit Esmeijer


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


P: n/a
See microsoft.public.dotnet.framework.drawing for many discussions on
drawing/printing things.

That said, you want to use a StringFormat.GenericTypographic to measure
and print the string as it provided better measurement for this. The
default StringFormat used in MeasureString some padding around the string
when measuring it. MeasureString returns values in the units selected for
the current Graphics.
You will also need to consider printer hard margins when printing as 0,0
starts at the top/left of the printable area by default. Using Framework
1.1 you can set OriginAtMargins to true and then 0,0 will be at the
intersection of your left and top margins.
I basically wrote my own set of printing utilities to do my printing so
that I have methods to align a string at a point including left and center
aligning. This was a rewrite of the utilities I've been using ever since I
was writing Postscript code to draw custom forms on the early Apple
Laserwriters.
If you actually want to get the printer's hard margins and printable
extent I have some C# routines that you can have.

Ron Allen
"G.Esmeijer" <ge****@nomail.nl> wrote in message
news:41**********************@dreader2.news.tiscal i.nl...
Friends,

I'm (a bit) dissapointed about the printing possibilities in c#. It could
also be lack of knowedge.

I would like to align a text on the right side of the paper when printing.

For example
tekst = DateTime.Today.Date.ToString("dd-MM-yyyy");
// asign content to the variable tekst
SizeF stringSize= ev.Graphics.MeasureString(tekst, printFont);
// measure the length of the tekst ... in what??
xPos = (float) ev.MarginBounds.Right - stringSize;
// to aligh it on thr right side of the paper
ev.Graphics.DrawString (tekst, printFont, Brushes.Black, xPos, yPos, new
StringFormat());

I would like to print tekst now but I have problems with the typing.

I tried all kinds of things but there must be some easy way of doing this.
Who can help me with this..

and who knows a bunch of nice printing functions. I dont like the way C#
handles the printer control.

regards
Gerrit Esmeijer

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.