PlainTextDocument Constructor (Stream, LoadOptions)

Creates a plain text document from a stream. Allows to specify additional options such as an encryption password.

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

Parameters

stream
Type: System.IOStream
The stream where to extract the text from.
loadOptions
Type: Aspose.WordsLoadOptions
Additional options to use when loading a document. Can be null.
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