PdfDocument.GetImages
Returns an array of ImageInformation objects of all the images present in the document.
public ImageInformation[] GetImages()
Function GetImages() As ImageInformation[]
Returns
An array of ImageInformation objects of all the images present in the document.
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 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.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 GetImages(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.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);
}
}
}
Remarks
This method returns image information only when the license key is applied and it will not work in evaluation mode.