officefileapi-devexpress-dot-pdf-dot-pdfdocumentprocessor-dot-getdximages-x28-devexpress-dot-pdf-dot-pdfdocumentarea-x29.md
Retrieves the images found in the specified document area. Use this method in non-Windows environments.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Docs.v25.2.dll
NuGet Package : DevExpress.Document.Processor
public IList<DXBitmap> GetDXImages(
PdfDocumentArea area
)
Public Function GetDXImages(
area As PdfDocumentArea
) As IList(Of DXBitmap)
| Name | Type | Description |
|---|---|---|
| area | PdfDocumentArea |
A page area from which the images should be retrieved.
|
| Type | Description |
|---|---|
| IList<DXBitmap> |
A collection of DXBitmap objects.
|
The overloaded GetDXImages method uses the page coordinate system. See the following topic for more information: Coordinate Systems.
The following code retrieves images from the specified page area:
using System;
using System.Collections.Generic;
using DevExpress.Drawing;
using DevExpress.Pdf;
// ...
PdfDocumentProcessor processor = new PdfDocumentProcessor();
processor.LoadDocument(@"..\\..\\Demo.pdf");
int xCount = 8;
int yCount = 2;
double cardWidth = 150.5; // Measured in points (equals 2.09 inches).
double cardHeight = 442; // Measured in points (equals 6.138 inches).
double xMargin = 122; // Measured in points (equals 1.694 inches).
double yMargin = 77; // Measured in points (equals 1.069 inches).
double yCoord = yMargin;
for (int y = 0; y < yCount; y++, yCoord += cardHeight) {
double xCoord = xMargin;
for (int x = 0; x < xCount; x++, xCoord += cardWidth) {
PdfDocumentArea area = new PdfDocumentArea(1,
new PdfRectangle(xCoord, yCoord, xCoord + cardWidth, yCoord + cardHeight));
IList<DXBitmap> bitmaps = processor.GetDXImages(area);
if (bitmaps.Count != 0) {
bitmaps[0].Save(String.Format(@"{0}_{1}.bmp", x, y), DXImageFormat.Bmp);
bitmaps[0].Dispose();
}
Console.WriteLine(bitmaps.Count.ToString());
}
}
Imports DevExpress.Drawing
Imports DevExpress.Pdf
Shared Sub Main(ByVal args() As String)
Dim processor As New PdfDocumentProcessor()
processor.LoadDocument("..\\..\\Demo.pdf")
Dim xCount As Integer = 8
Dim yCount As Integer = 2
Dim cardWidth As Double = 150.5 ' Measured in points (equals 2.09 inches).
Dim cardHeight As Double = 442 ' Measured in points (equals 6.138 inches).
Dim xMargin As Double = 122 ' Measured in points (equals 1.694 inches).
Dim yMargin As Double = 77 ' Measured in points (equals 1.069 inches).
Dim yCoord As Double = yMargin
Dim y As Integer = 0
Do While y < yCount
Dim xCoord As Double = xMargin
Dim x As Integer = 0
Do While x < xCount
Dim area As New PdfDocumentArea(1, New PdfRectangle(xCoord, yCoord, xCoord + cardWidth, yCoord + cardHeight))
Dim bitmaps As IList(Of DXBitmap) = processor.GetDXImages(area)
If bitmaps.Count <> 0 Then
bitmaps(0).Save(String.Format("{0}_{1}.bmp", x, y), DXImageFormat.Bmp)
bitmaps(0).Dispose()
End If
Console.WriteLine(bitmaps.Count.ToString())
x += 1
xCoord += cardWidth
Loop
y += 1
yCoord += cardHeight
Loop
End Sub
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the GetDXImages(PdfDocumentArea) 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.
pdf-document-api-extract-images-from-document/CS/PdfProcessorGetImages/Program.cs#L30
new PdfRectangle(xCoord, yCoord, xCoord + cardWidth, yCoord + cardHeight));
IList<DXBitmap> bitmaps = processor.GetDXImages(area);
if (bitmaps.Count != 0) {
See Also