Convert PDF to JPG in C#

Converter PDF to JPG / PDF to JPEG

This code sample shows how to convert PDF to JPG or JPEG in C#. Download a free trial of PDFRasterizer.NET 3.0 to try the PDF to JPG / PDF to JPEG converter.

static void Main(string[] args)
{
	//open the input pdf and select the first page
	Document pdfDocument = new Document(new FileStream("input.pdf", FileMode.Open, FileAccess.Read));
	Page pdfPage = pdfDocument.Pages[0];

	//create a bitmap to draw to and a graphics object
	using (Bitmap bitmap = new Bitmap((int)pdfPage.Width, (int)pdfPage.Height))
	using (Graphics graphics = Graphics.FromImage(bitmap))
	{
		//draw the image from the first page to the graphics object, which is connected to the bitmap object
		pdfPage.Draw(graphics);
		bitmap.Save("out.jpg", ImageFormat.Jpeg);
	}

	//open the bitmap in the standard application
	System.Diagnostics.Process.Start("out.jpg");
}
Download PDFRasterizer.NET 3.0
We will send you a download link
Why do we ask your email address?
We send tips that speed up your evaluation
We let you know about bug fixes
You can always unsubscribe with one click
We never share your address with a 3rd party
Thank you for your download

We have sent an email with a download link. Alternatively, you may want to use the NuGet package manager to install our library.

Nuget ID

Use the NugetID and start right away, or download the package and install it handmatically