Convert PDF to Image

26 Apr 20242 minutes to read

This PDF to image converter library allows converting PDF documents to images without opening the document in the PDF Viewer control. It allows you to selectively export pages as a stream by utilizing the ‘Convert’ method, facilitating the transformation of PDF files into images.

Watch the following video to quickly get started with converting PDF to image in .NET using a PDF to Image Converter Library.

NuGet

Platform(s) NuGet Package
Windows Forms

Syncfusion.PdfToImageConverter.WinForms.nupkg

WPF

Syncfusion.PdfToImageConverter.WPF.nupkg

ASP.NET Core Windows

Syncfusion.PdfToImageConverter.Net.nupkg

ASP.NET MVC Windows

Syncfusion.PdfToImageConverter.AspNet.Mvc4.nupkg


Syncfusion.PdfToImageConverter.AspNet.Mvc5.nupkg

NOTE

The above mentioned NuGet packages are available in nuget.org.

The following code snippet illustrates how to convert PDF page into image using Convert method in PdfToImageConverter.

//Initialize PDF to Image converter.
PdfToImageConverter imageConverter = new PdfToImageConverter();
//Load the PDF document as a stream
FileStream inputStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.ReadWrite);
imageConverter.Load(inputStream);
//Convert PDF to Image.
Stream outputStream = imageConverter.Convert(0, false, false);
MemoryStream stream = outputStream as MemoryStream;
return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Image.Jpeg, "sample.jpeg");
//Initialize PDF to Image converter.
PdfToImageConverter imageConverter = new PdfToImageConverter();
//Load the PDF document as a stream
FileStream inputStream = new FileStream("Input.pdf", FileMode.Open, FileAccess.ReadWrite);
imageConverter.Load(inputStream);
//Convert PDF to Image.
Stream outputStream = imageConverter.Convert(0, false, false);
Bitmap image = new Bitmap(outputStream);
image.Save("sample.png");
'Initialize PDF to Image converter.
Dim imageConverter As PdfToImageConverter = New PdfToImageConverter()
'Load the PDF document as a stream
Dim inputStream As FileStream = New FileStream("Input.pdf", FileMode.Open, FileAccess.ReadWrite)
imageConverter.Load(inputStream)
'Convert PDF to Image.
Dim outputStream As Stream = imageConverter.Convert(0, False, False)
Dim image As Bitmap = New Bitmap(outputStream)
image.Save("sample.png")

You can download a complete working sample from GitHub.