title: How to export PDF page as an image using PDFsharp .NET library?
body: <p>How to export a PDF page as an image using PDFsharp .NET library, for pixel level manipulation?</p>
  
  <p>For example, something like, System.Drawing.BitMap.GetPixel()</p>
  
  <p>I am trying to find out empty area (all white, or of any colour) inside a PDF document, to write some graphics / image.</p>
  
  <p><strong>09, June 2010:</strong></p>
  
  <p>I have tried this, but it is not working.</p>
  
  <p>Why the following code is not working as expected?</p>
  
  <p>Bitmap.GetPixel always returns 0.</p>
  
  <pre><code>//
  // PdfSharp.Pdf.PdfDocument
  // PdfSharp.Pdf.PdfPage
  // PdfSharp.Drawing.XGraphics
  // System.Drawing.Bitmap
  //
  string srcPDF = @"C:\hcr\test\tmp\file1.pdf";
  PdfDocument pdfd = PdfReader.Open(srcPDF);
  XGraphics xgfx = XGraphics.FromPdfPage(pdfd.Pages[0]);
  Bitmap b = new Bitmap((int) pdfp.Width.Point, (int) pdfp.Height.Point, xgfx.Graphics);
  
  int rgb = b.GetPixel(0, 0).ToArgb();
  </code></pre>