title: Changing text color in PdfSharp
body: <p>I'm currently creating a PDF with PdfSharp which mostly consists of text and some images.
  The text elements have different colors. My problem is that as soon as I use a different color than the color I started with, the text is not visible in the resulting PDF (e.g. I start with black text, switch to a red text, the red text is not visible). All text elements are in the resulting PDF (I can select them), but the red elements are invisible.</p>
  
  <p>So here is the code:</p>
  
  <pre><code>// Create a new PDF document with one page
  var document = new PdfDocument();
  var page = document.AddPage();
  page.Width = 800;
  page.Height = 600;
  var defaultFont = new XFont("Arial", 12, XFontStyle.Regular, new XPdfFontOptions(PdfFontEmbedding.Always));
  var gfx = XGraphics.FromPdfPage(page);
  
  // black text
  gfx.DrawString("black", defaultFont, XBrushes.Black, new XRect(x, y, width, height), XStringFormats.Center);
  
  // red text
  gfx.DrawString("red", defaultFont, XBrushes.Red, new XRect(x2, y2, width2, height2), XStringFormats.Center);
  </code></pre>
  
  <p>I've already found a solution (re-creating the XGraphics object) but it's quiete messy because it needs to be called after each color change:</p>
  
  <pre><code>// ...
  
  // black text
  gfx.DrawString("black", defaultFont, XBrushes.Black, new XRect(x, y, width, height), XStringFormats.Center);
  
  // disposing the old graphics context and creating a new one seems to help
  gfx.Dispose();
  gfx = XGraphics.FromPdfPage(page);
  
  // red text
  gfx.DrawString("red", defaultFont, XBrushes.Red, new XRect(x2, y2, width2, height2), XStringFormats.Center);
  </code></pre>
  
  <p>I guess there is a better solution, but I couldn't find one yet.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>As suggested in this <a href="https://stackoverflow.com/a/23969697/333404">answer</a>, I wanted to create a SSCCE. During the creation I found the actual bug. Instead of <code>XBrushes.Red</code> I used an own defined XBrush, but didn't mention it in the above code snippet, because I thought it was unnecessary.</p>