C# Convert PDF to Image

Why Convert PDF to Image

PDF is one of the most popular file formats. But it requires an external application like Adobe Acrobat Reader to read it while most of images don’t need that. Furthermore, most of browsers have built-in capability to display images but when they deal with PDF documents, an external application or plug-in is necessary. Microsoft Office applications also do a better job of handling images in comparison to PDF. To cite an example, a PowerPoint presentation with an embedded image goes faster than with a PDF document. At last, an external application comes with the handicap of loading times. Plus the rendering of a PDF document happens only after the complete document is downloaded while images can be streamed in.

How to Convert PDF to Image with C#

This solution we introduce will use the component of Adobe Acrobat 9.0 to convert each page of PDF document to images.

Develop Environment: VS2010, .Net Framework4.0, Adobe Acrobat9.0

Add COM reference: Adobe Acrobat 9.0 Type Library

Steps of PDF to Image conversion by Using C#:

  • Open PDF File
  • Get each page of PDF document
  • Acquire the size of each page and generate areas
  • Program the areas to be images and copy to clipboard.
  • Get the images from clipboard and save as images

Full Code:

        public static void ConvertPdf2Image(string pdfFilePath, string imageDirectoryPath,
            int beginPageNum, int endPageNum, ImageFormat format, double zoom = 1) {

            Acrobat.CAcroPDDoc pdfDoc = null;
            Acrobat.CAcroPDPage pdfPage = null;
            Acrobat.CAcroRect pdfRect = null;
            Acrobat.CAcroPoint pdfPoint = null;

            //Generate Com object to operate Pdf
              pdfDoc = (Acrobat.CAcroPDDoc)Microsoft.VisualBasic.Interaction.CreateObject("AcroExch.PDDoc", "");

            //Check input parameters
              if (!pdfDoc.Open(pdfFilePath)) {
                throw new FileNotFoundException(string.Format("original file{0}don’t exist!", pdfFilePath));

            if (!Directory.Exists(imageDirectoryPath)) {

            if (beginPageNum pdfDoc.GetNumPages() || endPageNumendPageNum) {
                throw new ArgumentException("parameter\"beginPageNum\"< \"endPageNum\"!");

            if (format == null) {
                format = ImageFormat.Png;

            if (zoom

Besides using Adobe Acrobat to convert PDF to image, there are still other solutions such as by using C# and GhostScript.

Click to details

If you just want to extract PDF image out and save, you can have a try on Spire.PDF.

Click to details 
Affiliate Advertisement:

Leave a Reply