| title | Convert PDF file to Image in ASP.NET MVC | Syncfusion |
|---|---|
| description | Learn how to convert a PDF file to Image in ASP.NET MVC with easy steps using System Drawing library. |
| platform | file-formats |
| control | PDF to image |
| documentation | UG |
| keywords | Assemblies |
The Syncfusion® PDF to Image converter is a .NET library used to convert PDF document to image in ASP.NET MVC application.
Step 1: Create a new C# ASP.NET Web Application (.NET Framework) project.

Step 2: In the project configuration windows, name your project and select Create.


Step 3: Install Syncfusion.PdfToImageConverter.AspNet.Mvc5 NuGet package as reference to your .NET applications from NuGet.org.
Step 4: Include the following namespaces in the HomeController.cs file.
{% highlight c# tabtitle="C#" %}
using Syncfusion.PdfToImageConverter; using System.Drawing; using System.IO;
{% endhighlight %}
Step 5: Add a new button in the Index.cshtml as shown below.
{% highlight c# tabtitle="C#" %}
@{Html.BeginForm("ExportToImage", "Home", FormMethod.Post); {
{% endhighlight %}
Step 6: Add a new action method named ExportToImage in HomeController.cs and include the below code example to convert PDF document to Image using Convert method in PdfToImageConverter class.
{% highlight c# tabtitle="C#" %}
//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");
{% endhighlight %}
By executing the program, you will get the image as follows.
