title: C# Printing with Font Styles
body: <p>I want to print some text like this.</p>
  
  <blockquote>
    <p>This is <strong>how</strong> i want to <strong>print</strong> the text.</p>
  </blockquote>
  
  <p>the code i am using is</p>
  
  <pre><code>private void button3_Click(object sender, EventArgs e)
      {
          stringToPrint = "This is how i want to print the text";
          printFont = new Font("Times New Roman", 10);
          pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
          try
          {
              pd.Print();
          }
          catch (Exception e)
          {
          }
      }
  
  void pd_PrintPage(object sender, PrintPageEventArgs ev)
      {
          int charactersOnPage = 0;
          int linesPerPage = 0;
  
          ev.Graphics.MeasureString(stringToPrint, printFont,
              ev.MarginBounds.Size, StringFormat.GenericTypographic,
              out charactersOnPage, out linesPerPage);
  
          ev.Graphics.DrawString(stringToPrint, printFont, Brushes.Black,
              ev.MarginBounds, StringFormat.GenericTypographic);
  
          stringToPrint = stringToPrint.Substring(charactersOnPage);
  
          ev.HasMorePages = (stringToPrint.Length &gt; 0);
  
      }
  </code></pre>
  
  <p>I want to change the Font from regular to bold or give an Underline for some specific words in the string.</p>
  
  <p>And if there is another Better way to do this job then please tell me i'll change my code.
  Please Help me Out! :)</p>