aewarnick Posted April 5, 2003 Posted April 5, 2003 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? Quote C#
Ariez Posted April 5, 2003 Posted April 5, 2003 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. Quote Auto-suggestion: "I have a life" Uncontroled thinking: "So what the.."
Moderators Robby Posted April 5, 2003 Moderators Posted April 5, 2003 Ariez, is 'mastering VB.net in pdf' a book/CD? Quote Visit...Bassic Software
Guest mutant Posted April 5, 2003 Posted April 5, 2003 It has to be an eBook, thats the only thing PDF and Acrobat is good for :) Quote
Ariez Posted April 5, 2003 Posted April 5, 2003 pdf, pretty good book. Quote Auto-suggestion: "I have a life" Uncontroled thinking: "So what the.."
aewarnick Posted April 7, 2003 Author Posted April 7, 2003 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? Quote C#
a_jam_sandwich Posted April 7, 2003 Posted April 7, 2003 Im sorting a control out for Rich Text on my site soon. Andy Quote Code today gone tomorrow!
aewarnick Posted April 8, 2003 Author Posted April 8, 2003 That brings up a good topic. Why does Ms put a char limit for a RT box and how can I overcome that? Quote C#
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.