Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

PdfDocumentProcessor.GetImagesInfo(PdfDocumentArea) Method

Retrieves images and their boundaries found within the specified document area.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Docs.v24.2.dll

NuGet Package: DevExpress.Document.Processor

#Declaration

public IList<PdfBitmapBox> GetImagesInfo(
    PdfDocumentArea area
)

#Parameters

Name Type Description
area PdfDocumentArea

A PdfDocumentArea object that represents a document area.

#Returns

Type Description
IList<PdfBitmapBox>

A collection of PdfBitmapBox objects.

#Remarks

The overloaded GetImagesInfo method uses the page coordinate system. See the following topic for more information: Coordinate Systems.

The following example uses the GetImagesInfo(PdfDocumentArea) method to obtain all images and their boundaries from the specified page and to draw a red rectangle around them.

pdf-document-api-extract-images-with-boundaries

using DevExpress.Drawing;
using DevExpress.Pdf;
using System.Collections.Generic;
using System.Drawing;
// ...
static void Main(string[] args) {

    using (PdfDocumentProcessor processor = new PdfDocumentProcessor()) {
        processor.LoadDocument(@"..\\..\\Demo.pdf");
        // Specify the area from which the images are obtained.
        PdfDocumentArea area = new PdfDocumentArea(1,
            new PdfRectangle(0, 0, processor.Document.Pages[0].CropBox.Width, 
                processor.Document.Pages[0].CropBox.Height));
        // Retrieve images and their boundaries.
        IList<PdfBitmapBox> bitmaps = processor.GetImagesInfo(area);
        // Draw a rectangle around boundaries of each image.
        for (int i = 0; i < bitmaps.Count; i++) {
            var r = bitmaps[i].Bounds;
            float rectFLeft = (float)r.Left;
            float rectFTop = (float)(processor.Document.Pages[0].CropBox.Height - r.Top);
            float rectFWidth = (float)r.Width; 
            float rectFHeight = (float)r.Height;

            PdfGraphics graphics = processor.CreateGraphics();
            using (var pen = new DXPen(Color.Red, 5))
                graphics.DrawRectangle(pen, new RectangleF(rectFLeft, rectFTop, rectFWidth, rectFHeight));
                graphics.AddToPageForeground(processor.Document.Pages[1], 72, 72);
        }
        // Print the resulting document.
        DXBitmap bitmap = processor.CreateDXBitmap(1, 1000);
        PdfPrinterSettings pdfPrinterSettings = new PdfPrinterSettings();
        processor.Print(pdfPrinterSettings);
    }
}
See Also