Monday, March 26, 2007

Printing Documents

There are times when a program needs a printing function. However, the PrintDocument class provided in .NET seems to raw, requiring one to measure of each word in a string, and lay it out on the page. There must be a better way, and after some searches, I found the gem below. How to print the content of a RichTextBox control by using Visual C# .NET or Visual C# 2005 http://support.microsoft.com/kb/812425 And the Rich Text Format specification http://www.biblioscape.com/rtf15_spec.htm With this, Windows will layout the text for you. Say goodbye to MeasureString!

No comments: