Skip to main content

PdfDocumentProcessor.CreateBitmap(Int32, Int32) Method

Exports a PDF page to a bitmap image.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Docs.v23.2.dll

NuGet Package: DevExpress.Document.Processor

Declaration

public Bitmap CreateBitmap(
    int pageNumber,
    int largestEdgeLength
)

Parameters

Name Type Description
pageNumber Int32

A page number.

largestEdgeLength Int32

A length of the image’s largest dimension, in pixels.

Returns

Type Description
Bitmap

The converted page.

Remarks

The largestEdgeLength parameter determines the output image height for pages in the portrait orientation and width – for landscape pages. The page is proportionally scaled so that the largest edge of the converted bitmap is equal to the largestEdgeLength value.

You can reduce the output image size and memory consumption if you pass a smaller largestEdgeLength value to the CreateBitmap method.

Warning

The CreateBitmap method uses GDI/GDI+ rendering and works only on Windows OS. The PlatformNotSupportedException is thrown on other operating systems. Use the CreateDXBitmap method in non-Windows environments.

Example

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

View Example

using DevExpress.Pdf;
using System.Drawing;

static void Main(string[] args)
{

  int largestEdgeLength = 1000;

  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