Skip to main content

PdfPage

Version: 11.0

cete.dynamicpdf.merger.pdfpage

PdfPage​

Represents a page from an imported PDF document.

public class PdfPage
Public Class PdfPage

Inheritance: Object → PdfPage

Methods​

Equals(Object)​

Determines whether the specified Object is equal to the current Object . (Inherited from Object)

public bool Equals(Object obj)
Function Equals(obj As Object) As Boolean

Parameters​

The Object to compare with the current Object .

Returns​

true if the specified Object is equal to the current Object ; otherwise, false.

GetContents()​

Returns the uncompressed binary contents of the page.

public Byte[] GetContents()
Function GetContents() As Byte()

Returns​

A byte array containing the pages contents.

GetDictionaryValue(String)​

Returns the value of a given page dictionary key.

public string GetDictionaryValue(string key)
Function GetDictionaryValue(key As String) As String

Parameters​

The dictionaries key.

Returns​

The dictionary key's value as a string.

GetDimensions()​

Gets the page dimensions of the page.

public PageDimensions GetDimensions()
Function GetDimensions() As PageDimensions

Returns​

A PageDimensions object.

GetFonts()​

Gets the informaton of all the fonts present in the page.

public FontInformation[] GetFonts()
Function GetFonts() As FontInformation[]

Returns​

An array of the FontInformation .

GetHashCode()​

Serves as a hash function for a particular type. (Inherited from Object)

public int GetHashCode()
Function GetHashCode() As Integer

Returns​

A hash code for the current Object .

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.

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);
}
}
}

GetNoteAnnotations()​

Gets the note annotations from the the PDF page.

public PdfNoteAnnotation[] GetNoteAnnotations()
Function GetNoteAnnotations() As PdfNoteAnnotation[]

Returns​

A array of note annotations present in the PDF page.

GetText()​

Gets the text in the page.

public string GetText()
Function GetText() As String

Returns​

A string containing the text in the page.

Examples​

The following example will extract the entire text of the specified page in the given PDF documents.

Imports System
Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.Merger

Module MyModule

Sub Main()

' Create PDF document object
Dim pdfA As PdfDocument = New PdfDocument( "C:\Invoice.pdf")

' Call GetText method from PDF document object to get the text from the document
Dim extractedText As String = pdfA.Pages.Item(1).GetText()

End Sub
End Module
using System;
using ceTe.DynamicPDF.Merger;

public class Example
{
public static void GetText(string inputPath)
{
// Create PDF document object
PdfDocument pdfA = new PdfDocument(inputPath);

// Call GetText method from PDF document object to get the text from the document
string extractedText = pdfA.Pages[0].GetText();
}
}

Remarks​

This method can be used to extract the text in the same order the pdf operators are loaded. Text extraction skips characters that are morethan 2 bytes. With some of the .Net runtimes (example: .Net Core 2.0), Text extraction will give the error "No data is available for encoding 1252. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.". To resolve this error refer the user manual page Encoding Considerations.

GetText(Single, Single, Single, Single)​

Gets the text in the specified rectangle of the page.

public string GetText(float x, float y, float width, float height)
Function GetText(x As Single, y As Single, width As Single, height As Single) As String

Parameters​

X coordinate of the rectangle.

Y coordinate of the rectangle.

Width of the rectangle.

Height of the rectangle.

Returns​

A string containing the text in the specified rectangle of the page.

Remarks​

This method can be used to extract the text in the same order the pdf operators are loaded. Text extraction skips characters that are morethan 2 bytes.

GetType()​

Gets the Type of the current instance. (Inherited from Object)

public Type GetType()
Function GetType() As Type

Returns​

The Type instance that represents the exact runtime type of the current instance.

ToString()​

Returns a String that represents the current Object . (Inherited from Object)

public string ToString()
Function ToString() As String

Returns​

A String that represents the current Object .

See Also​

ceTe.DynamicPDF.Merger