The answer can be found in the PDFsharp FAQ list:
http://www.pdfsharp.net/wiki/PDFsharpFAQ.ashx#Can_PDFsharp_show_PDF_files_Print_PDF_files_Create_images_from_PDF_files_3
PDFsharp creates PDF files, but it cannot render them.
The call
Bitmap b = new Bitmap((int) pdfp.Width.Point, (int) pdfp.Height.Point, xgfx.Graphics);
does not initialize any bits of the bitmap and does not copy anything from the Graphics object except for the DPI setting of the Graphics object. Graphics objects draw things, but they do not remember what they have drawn and they cannot re-create the drawings in a call to new Bitmap(...)
. This does not work with the Graphics class from Microsoft, this does not work with the XGraphics class from PDFsharp either.
The XGraphics class from PDFsharp can be used to draw on PDF pages and it can be used to draw on bitmaps, on a printer, or on the screen – it can draw on PDF pages and on any DC you can get from Windows. Same goes for MigraDoc.
So if you want to create PDF files and bitmaps with the same contents, PDFsharp and MigraDoc can help.
But PDFsharp does not provide any way to render a PDF page to a bitmap.