The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.

How to: Export a PDF Document to a Bitmap

  • 2 min to read
Important

You require a license to the DevExpress Office File API or DevExpress Universal Subscription to use these examples in production code. Refer to the DevExpress Subscription page for pricing information.

The following example demonstrates how to export pages to bitmap images.

Important

The CreateBitmap method uses GDI/GDI+ rendering and works only on Windows OS. The PlatformNotSupportedException is thrown on other operating systems.

Follow the steps below to perform the export:

  • Create a PdfDocumentProcessor instance and load the PDF document using the overloaded PdfDocumentProcessor.LoadDocument method.
  • Call the PdfDocumentProcessor.CreateBitmap method using the page number and thelargestEdgeLength parameter (measured in pixels). This parameter determines the output image's height for pages in the portrait orientation and width for landscape pages.
  • Save the converted bitmap images to a file using the overloaded Bitmap.Save method.

using DevExpress.Pdf;
using System.Drawing;

namespace ExportToBitmap
{
    class Program
    {

        static void Main(string[] args)
        {

            int largestEdgeLength = 1000;

            // Create a PDF Document Processor.
            using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
            {
                // Load a document.
                processor.LoadDocument("..\\..\\Document.pdf");

                for (int i = 1; i <= processor.Document.Pages.Count; i++) {

                    // Export pages to bitmaps.
                    Bitmap image = processor.CreateBitmap(i, largestEdgeLength);

                    // Save the bitmaps.
                    image.Save("..\\..\\MyBitmap" + i + ".bmp");
                }
            }
        }
    }
}