Convert a PDF to BMP

Convert PDF
7/3/2014

This code sample explains the most basic way to convert a PDF to BMP.

1 static void Main(string[] args) 2 { 3 //open the input pdf and select the first page 4 Document pdfDocument = new Document(new FileStream("input.pdf", FileMode.Open, FileAccess.Read)); 5 Page pdfPage = pdfDocument.Pages[0]; 6 7 //create a bitmap to draw to and a graphics object 8 using (Bitmap bitmap = new Bitmap((int)pdfPage.Width, (int)pdfPage.Height)) 9 using (Graphics graphics = Graphics.FromImage(bitmap)) 10 { 11 //draw the image from the first page to the graphics object, which is connected to the bitmap object 12 pdfPage.Draw(graphics); 13 bitmap.Save("out.png"); 14 } 15 16 //open the bitmap in the standard application 17 System.Diagnostics.Process.Start("out.png"); 18 }