Print Richtextbox content with Formating in C# Windows Forms

I just published article on my blog here about printing Text From richTextBox but it only prints Text what about printing some Text with all the font formatting you have done inside theRichTextBox we will follow pretty similar manner using draw string method of the Graphics object

Summary of how we printing text here

  1. We Select one character and draw it on document including font color Font Type etc. .
  2. When we encounter \n we move Y Coordinate variable to +10 in Y Axis so it will be at new Line

That's it. very simple basic intention of article is yo make you start with printing formatted content the below code works for only Courier New Font but you can modify the code to make it work with others too .

7-18-2011 9-45-55 PM.gif

7-18-2011 10-21-11 PM.gif

Note :You need to Set position of X variable according to font you use in richtext box I used x+8 because it is appropriate for Courier New font .

Up Next
    Ebook Download
    View all
    Learn
    View all