PdfPage.GetImages
Gets the informaton of all the images present in the page.
public ImageInformation[] GetImages()
Function GetImages() As ImageInformation[]
Returns
An array of ImageInformation object for all the images present in the page.
Licensing Info
This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
Examples
The following example will extract the images in the specified page in the given PDF document.Imports System
Imports System.IO
Imports ceTe.DynamicPDF.Merger
Module MyModule
Sub Main()
' Create PDF document object
Dim pdfA As PdfDocument = New PdfDocument( "C:\Input.pdf")
' Call GetText method from PDF document object to get the text from the document
Dim imageInfoList As ImageInformation() = pdfA.Pages.Item(1).GetImages()
For i As Integer = 0 To imageInfoList.Length - 1
Dim extractedImageData As ExtractedImageData = imageInfoList(i).GetImage()
Dim data As Byte() = Nothing
Dim extension As String = ""
If extractedImageData.ExtractedImageType = ExtractedImageType.Png Then
extension = ".png"
Else
extension = ".jpg"
End If
data = extractedImageData.Data
File.WriteAllBytes("C:\Output\image" & i & extension, data)
Next
End Sub
End Module
using System;
using System.IO;
using ceTe.DynamicPDF.Merger;
public class Example
{
public static void GetText(string inputPath, string outputPath)
{
// Create PDF document object
PdfDocument pdfA = new PdfDocument(inputPath);
// Call GetImages method from PDF document object to get the images from the document
ImageInformation[] imageInfoList = pdf.Pages[0].GetImages();
for (int i = 0; i < imageInfoList.Length; i++)
{
ExtractedImageData extractedImageData = imageInfoList[i].GetImage();
byte[] data = null;
string extension = "";
if (extractedImageData.ExtractedImageType == ExtractedImageType.Png)
extension = ".png";
else
extension = ".jpg";
data = extractedImageData.Data;
File.WriteAllBytes(outputPath + i + extension, data);
}
}
}