PlainTextDocument Constructor (Stream)

Creates a plain text document from a stream. Automatically detects the file format.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public PlainTextDocument(
	Stream stream
)

Parameters

stream
Type: System.IOStream
The stream where to extract the text from.
Exceptions
ExceptionCondition
UnsupportedFileFormatExceptionThe document format is not recognized or not supported.
FileCorruptedExceptionThe document appears to be corrupted and cannot be loaded.
ExceptionThere is a problem with the document and it should be reported to Aspose.Words developers.
IOExceptionThere is an input/output exception.
IncorrectPasswordExceptionThe document is encrypted and requires a password to open, but you supplied an incorrect password.
ArgumentNullExceptionThe stream cannot be null.
NotSupportedExceptionThe stream does not support reading or seeking.
ObjectDisposedExceptionThe stream is a disposed object.
Remarks
Remarks

The document must be stored at the beginning of the stream. The stream must support random positioning.

Examples
Show how to simply extract text from a stream.
TxtLoadOptions loadOptions = new TxtLoadOptions { DetectNumberingWithWhitespaces = false };

Stream stream = new FileStream(MyDir + "Document.docx", FileMode.Open);

PlainTextDocument plaintext = new PlainTextDocument(stream);

plaintext = new PlainTextDocument(stream, loadOptions);
See Also