Skip to main content

PdfViewer.CreateBitmap(Int32, Int32) Method

Exports a PDF page to a bitmap image.

Namespace: DevExpress.XtraPdfViewer

Assembly: DevExpress.XtraPdfViewer.v23.2.dll

NuGet Package: DevExpress.Win.PdfViewer

Declaration

public Bitmap CreateBitmap(
    int pageNumber,
    int largestEdgeLength
)

Parameters

Name Type Description
pageNumber Int32

An integer value, specifying the page number.

largestEdgeLength Int32

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

Returns

Type Description
Bitmap

A Bitmap object.

Remarks

The CreateBitmap method has two parameters: the converted page’s number and the length of the image’s largest dimension in pixels. The largestEdgeLength 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 is not clipped when it is converted to bitmap. The page is proportionally scaled so that the largest edge of the converted bitmap is equal to the largestEdgeLength value.

The code sample below exports pages to bitmap images.

int largestEdgeLength = 1000;

pdfViewer1.LoadDocument("Document.pdf");
for (int i = 1; i <= pdfViewer1.PageCount; i++)
{
    // Export all pages to bitmaps
    Bitmap image = pdfViewer1.CreateBitmap(i, largestEdgeLength);

    // Save the resulting images
    image.Save("..\\..\\MyBitmap" + i + ".bmp");
}
See Also