Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

PdfDocumentProcessor.CreateBitmap(Int32, Int32) Method

Exports a PDF page to a bitmap image.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Docs.v19.1.dll

Declaration

public Bitmap CreateBitmap(
    int pageNumber,
    int largestEdgeLength
)

Parameters

Name Type Description
pageNumber Int32

An integer value, specifying the converted page’s number.

largestEdgeLength Int32

An integer value, specifying the length of the image’s largest dimension, in pixels.

Returns

Type Description
Bitmap

A Bitmap object.

Remarks

Note

The CreateBitmap method works on Azure Windows Virtual Machines and does not work on Azure Web Apps.

The CreateBitmap method has two parameters: the converted page’s number and the length of the image’s largest dimension in pixels. The latter parameter determines the output image height for pages in the portrait orientation and width - for landscape pages.

You can reduce the output image size and memory consumption if you pass a smaller largestEdgeLength value to the CreateBitmap method. The document page will not be clipped when it is converted to bitmap. The page will be proportionally scaled so that the largest edge of the converted bitmap is equal to the largestEdgeLength value.

Important

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

Example

The following example illustrates how to convert pages to bitmap images.


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");
                }
            }
        }
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the CreateBitmap(Int32, Int32) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also