.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+

PdfDocumentProcessor.CreateBitmap(Int32, Int32) Method

Exports a PDF page to a bitmap image.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Docs.v19.2.dll

Declaration

public Bitmap CreateBitmap(
    int pageNumber,
    int largestEdgeLength
)
Public Function CreateBitmap(
    pageNumber As Integer,
    largestEdgeLength As Integer
) As Bitmap
public Bitmap CreateBitmap(
    int pageNumber,
    int largestEdgeLength
)
Public Function CreateBitmap(
    pageNumber As Integer,
    largestEdgeLength As Integer
) As Bitmap
public Bitmap CreateBitmap(
    int pageNumber,
    int largestEdgeLength
)
Public Function CreateBitmap(
    pageNumber As Integer,
    largestEdgeLength As Integer
) As Bitmap

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.

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.

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.

Returns

Type Description
Bitmap

A Bitmap object.

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