Why can't I find any good documentation on printing?

aewarnick

Senior Contributor
Joined
Jan 29, 2003
Messages
1,031
All I have found on the internet and VS is how to print text. And that is not very helpful in itself! Here is an example which is better than the documentation VS had, but there are still problems with how to accomodate word wrap that occurs because of the margins:

private void printDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
float linesPerPage= e.MarginBounds.Height/this.RTB.Font.GetHeight(e.Graphics);
string[]lines= this.RTB.Text.Split('\n');
for(int i=0; i<linesPerPage; i++)
{
if(i==lines.Length) break;
float yPos= e.MarginBounds.Top + (i * this.RTB.Font.GetHeight(e.Graphics));
Rectangle R=new Rectangle(e.MarginBounds.Left, Convert.ToInt32(yPos), e.MarginBounds.Width, e.MarginBounds.Height);
e.Graphics.DrawString(lines, this.RTB.Font, Brushes.Red, R, new StringFormat());
}

The problem with that code is, like I said, the word wrap that the margins cause. When a string is too long it wraps which is great! But the rest of the document continues on the line that it was going to be on and it over-writes the wrapped text.

I guess my thought is that there is a better way to print. How does MS Word do it with all the different sizes of fonts and pictures?
 
I got mastering VB.net in pdf. Now even though youre in c#, theres a whole chapter on printing. it would give you a pretty good idea of what you can do. Methods are the same, calls syntax are a bit different...
if you got a 10MB mail capacity , post your address, ill send it to u.
 
Anyone have an e-book like that for C#? I don't really like pdf though. If it was an html book that would be better. But either way, I am learning.

Also, that e-book did not cover how to print anything but list view and plain text. Anyone know of any documentation on printing formatted text with pictures inside the text?
 
That brings up a good topic. Why does Ms put a char limit for a RT box and how can I overcome that?
 
Back
Top