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
public sealed class TextDevice : PageDevice

The TextDevice type exposes the following members.

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.
Public propertyCode exampleEncoding
Gets or sets encoding of extracted text.
Public propertyCode exampleExtractionOptions
Gets or sets text extraction options.
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.)
The TextDevice object is basically used to extract text from pdf page.
The example demonstrates how to extract text on the first PDF document page.
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
    extractedText = Encoding.Unicode.GetString(ms.ToArray());
See Also