Page Devices

This guide shows how to render PDF pages to image files using BmpDevice and PdfPageRenderer in Aspose.PDF FOSS for Java. You will learn to generate BMP thumbnails and use page rendering for image-based processing pipelines.

BmpDevice

BmpDevice renders a PDF page to a BMP image file. This is useful for generating thumbnails, document previews, and image-based pipelines. Call process(page, path) with a Page instance and an output file path to produce the BMP file.

try (Document doc = new Document("input.pdf")) {
    BmpDevice device = new BmpDevice();
    PageCollection pages = doc.getPages();
    Page page = pages.get(1);
    device.process(page, "page1.bmp");
}

The output is a standard BMP file that can be further processed with standard Java image libraries such as javax.imageio.

PdfPageRenderer

PdfPageRenderer renders PDF pages to image output. Use PdfPageRenderer when you need rendering output beyond what BmpDevice provides directly.

Use Cases

  • Thumbnail generation — render the first page of each document as a preview image
  • Document preview — display a specific page in an image viewer
  • Image pipelines — pass rendered page images to OCR or image analysis tools
  • Batch preview — iterate all pages and render each to a separate file
try (Document doc = new Document("input.pdf")) {
    BmpDevice device = new BmpDevice();
    PageCollection pages = doc.getPages();
    for (int i = 1; i <= pages.getCount(); i++) {
        Page page = pages.get(i);
        device.process(page, "page" + i + ".bmp");
    }
}

See Also

 English