TextDevice Class
Represents class for converting pdf document pages into text.
Inheritance Hierarchy

Namespace: Aspose.Pdf.Devices
Assembly: Aspose.PDF (in Aspose.PDF.dll) Version: 20.5
Syntax
public sealed class TextDevice : PageDevice

The TextDevice type exposes the following members.

Constructors
  NameDescription
Public methodTextDevice
Initializes a new instance of the TextDevice with the Raw text formatting mode and Unicode text encoding.
Public methodTextDevice(Encoding)
Initializes a new instance of the TextDevice for the specified encoding.
Public methodTextDevice(TextExtractionOptions)
Initializes a new instance of the TextDevice with text extraction options.
Public methodTextDevice(TextExtractionOptions, Encoding)
Initializes a new instance of the TextDevice for the specified encoding with text extraction options.
Properties
  NameDescription
Public propertyCode exampleEncoding
Gets or sets encoding of extracted text.
Public propertyCode exampleExtractionOptions
Gets or sets text extraction options.
Methods
  NameDescription
Public methodEquals (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodProcess(Page, String)
Perfoms some operation on the given page and saves results into the file.
(Inherited from PageDevice.)
Public methodCode exampleProcess(Page, Stream)
Convert page and save it as text stream.
(Overrides PageDeviceProcess(Page, Stream).)
Public methodToString (Inherited from Object.)
Remarks
The TextDevice object is basically used to extract text from pdf page.
Examples
The example demonstrates how to extract text on the first PDF document page.
C#
Document doc = new Document(inFile);
string extractedText;

using (MemoryStream ms = new MemoryStream())
{
    // create text device
    TextDevice device = new TextDevice();

    // convert the page and save text to the stream
    device.Process(doc.Pages[1], ms);

    // use the extracted text
    ms.Close();
    extractedText = Encoding.Unicode.GetString(ms.ToArray());
}
See Also