How to: Export a PDF Document to a Bitmap
- 2 minutes to read
Important
You need a license for the DevExpress Office File API Subscription or DevExpress Universal Subscription to use these examples in production code.
The following example demonstrates how to export pages to bitmap images.
Note
Set the PdfDocumentProcessor.RenderingEngine property to Skia to enable this method on Azure Web Apps.
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 the
largestEdgeLength
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.
Tip
Pass the PdfPageRenderingParameters instance as the CreateBitmap
method parameter to specify a predefined resolution for a PDF page exported to a Bitmap image.
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");
}
}
}
}
}