ASP.NET PDF to Image Converter Control
How to view, convert PDF to multiple images in web browser in ASP.NET MVC for Azure using C#?

How to read, view an existing PDF online, and convert modified PDF to images using C# in ASP.NET Core MVC web application.

Open, read, view and markup an existing PDF network file in ASP.NET using C# is very simple. EdgePDF provides a simple C# demo code to accomplish the job.

  • Convert PDF pages to raster images, such as PNG, GIF,Bitmap, JPEG.
  • Converted image with advanced options, such as resolution, zooming, colorspace
  • Easy to enable conversion feature in ASP.NET Forms, MVC web applications using C#

How to view, convert PDF to images programmatically in using C#

  1. Download EdgePDF PDF viewer web control
  2. Install EdgePDF demo project in IIS
  3. Follow step by step tutorial


To run the following tutorial successfully, we need the following setup ready.

  1. For ASP.NET Core web app: Setup EdgePDF
  2. For ASP.NET Core MVC web app: Setup EdgePDF
  3. For ASP.NET (.net framework): Setup EdgePDF on IIS
  4. Several demo PDF files in folder C:\temp\

How to read, view, a merged PDF from two PDF files online in ASP.NET C#?

The following steps and C# source code will learn how to view, edit a PDF file in web browser using C# ASP.NET, and export modified PDF to image files, one PDF page per PNG image file in the web server in ASP.NET web application.

After you have completed the following guide, you can open, view, comment a PDF file online through url (a sample url http://localhost:56643/?yourtarget=pdf-1.pdf)

To convert the modified PDF document to PNG image files in web server

  • Go to EdgePDF toolbar in web browser
  • Click tab "Customize"
  • Click command button "Save Server"

  • For ASP.NET Core web app, open file UserCommandProcessMiddleware.cs from /DemoProjects/EdgePDF for ASP.NET Core/

  • For ASP.NET (.net framework) project, open file UserCommandProcessHandler.ashx from {EdgePDF demo project}/RasterEdge_Resource_Files/

  • Go to method SaveFile_OnServer()
  • Create a new PDFDocument object with EdgePDF displayed PDF file loaded
  • Get the viewed PDF file name
  • Use method PDFDocument.ConvertToImages() save and convert the modified PDF document into PNG image files, one PDF page will produce one PNG file.

    public override void SaveFile_OnServer(String fid, String savePath, String responseMsg)
        //  You can process saved pdf document here, like add watermark, ...
        var documentPath = savePath;
        if (!String.IsNullOrEmpty(documentPath))
            Logger.LogFile(fid, "SaveFileOnServer: output file path " + documentPath, LogType.DEBUG);

            //  To verify the output file.
            RasterEdge.Imaging.Basic.BaseDocument document = null;
            if (documentPath.EndsWith(".pdf"))
                // document object includes user modified content
                document = new RasterEdge.XDoc.PDF.PDFDocument(documentPath);
            if (document != null)

                //  Get the upload information of the file
                RasterEdge.WDP.DocUploadInfo docinfo = RasterEdge.WDP.Manager.FileManager.getUploadinfoByFid(fid);
                //  Get your file open url parameters value, if needed.
                String paraFilepathValue = docinfo.GetRequestParameters("yourtarget");
                if (!String.IsNullOrEmpty(paraFilepathValue))
                        int startIdx = documentPath.LastIndexOf("/");
                        int endIdx = documentPath.LastIndexOf(".");
                        String docName = documentPath.Substring(startIdx + 1, endIdx - startIdx - 1) + "-";

                        document.ConvertToImages(ImageType.PNG, @"C:\temp", docName);

                    catch (Exception ex)
                        //  Process error code, and return error information here
                        Logger.LogFile(fid, ex.Message + ". fail to save file to server.", LogType.ERROR);
                    Logger.LogFile(fid, "no 'yourtarget' in the HTTPRequest.", LogType.INFO);
                Logger.LogFile(fid, "output PDF file is invalid.", LogType.ERROR);
            Logger.LogFile(fid, "fail to save file to server. output file path is null or empty.", LogType.ERROR);

After complete the ASP.NET PDF to images conversion web application, you could easily publish the app to Microsoft Azure cloud service. View details at How to deploy ASP.NET MVC PDF viewer web application to Azure?

More options to convert PDF pages to images using C# ASP.NET

The above C# ASP.NET source code explains how to quickly use method PDFDocument.ConvertToImages() to export a PDF file to images in ASP.NET web application.

Here we will provide more options for PDF to image conversion in ASP.NET web app.

Converted images resolution and zooming

In class PDFDocument, there are two methods which allow you to convert PDF page to image with specified image resolution or zooming value.

        public abstract void ConvertToImages(ImageType targetType, float zoomValue, string directory, string fileName);
        public abstract void ConvertToImages(ImageType targetType, int resolution, string directory, string fileName);

Images in Stream or Byte Array objects

If you need store the converted image objects into Stream objects or byte array, you could try the following API in class PDFDocument.

        public abstract void ConvertToImages(ImageType targetType, int resolution, Stream[] streams);
        public abstract void ConvertToImages(ImageType targetType, float zoomValue, Stream[] streams);
        public abstract void ConvertToImages(ImageType targetType, Stream[] streams);

Images with advanced options

If you need more image options, such as color space settings, you should try the following API. For more information about class ImageOutputOption , please go to page How to convert PDF to images with advanced image options applied

        public abstract void ConvertToImages(ImageOutputOption option, Stream[] streams);
        public abstract void ConvertToImages(ImageOutputOption option, string directory, string fileName);