title: How can I set a PDF paragraph's font using iTextSharp?
body: <p>Trying to follow the example <a href="https://web.archive.org/web/20211020001758/https://www.4guysfromrolla.com/articles/030911-1.aspx" rel="noreferrer">here</a>, I added the following code to create the title of a PDF doc:</p>
  
  <pre><code>using (var doc = new Document(PageSize.A4, 50, 50, 25, 25))
  {
      using (var writer = PdfWriter.GetInstance(doc, ms))
      {
          doc.Open();
  
          var docTitle = new Paragraph("UCSC Direct - Direct Payment Form");                        
          var titleFont = FontFactory.GetFont("Lucida Sans", 18, Font.Bold);
          doc.Add(docTitle);
  </code></pre>
  
  <p>However, the attempt to create titleFont wouldn't compile ("<em>The best overloaded method match for 'iTextSharp.text.FontFactory.GetFont(string, float, iTextSharp.text.BaseColor)' has some invalid arguments</em>"), so I let intellisenseless "help" me by adding one arg at a time. Since for the first arg it said it was the font name, a string, I added "Segoe UI"; the next arg was font size, a float, so I added 18.0; finally, it called for the font color, a BaseColor type, so I added BaseColor.Black, ending up with:</p>
  
  <pre><code>var titleFont = FontFactory.GetFont("Segoe UI", 18.0, BaseColor.BLACK);
  </code></pre>
  
  <p>...but that also won't compile, saying "<em>The best overloaded method match for 'iTextSharp.text.FontFactory.GetFont(string, string, bool)' has some invalid arguments</em>"</p>
  
  <p>So when I copied the example, and used string, int, and Font style, it said no, it wants string, float, and BaseColor. When I then added those arguments, it changed its "mind" and said what it really wants is string, string, and bool?</p>
  
  <p>Also, the example shows then adding the paragraph to the document like so:</p>
  
  <pre><code>doc.Add(docTitle, titleFont);
  </code></pre>
  
  <p>...but that won't fly, either, as "<em>No overload for method 'Add' takes 2 arguments</em>"</p>
  
  <p>What can I do to mollify iTextSharp? Whether I dance a jig or chant a dirge, it doesn't want to play along.</p>
  
  <h2>UPDATE</h2>
  
  <p>Okay, this compiles:</p>
  
  <pre><code>var docTitle = new Paragraph("UCSC Direct - Direct Payment Form");
  var titleFont = FontFactory.GetFont("Courier", 18, BaseColor.BLACK);
  docTitle.Font = titleFont;
  doc.Add(docTitle);
  </code></pre>