PlainTextDocument class
PlainTextDocument class
Allows to extract plain-text representation of the document’s content. To learn more, visit the Working with Text Document documentation article.
Constructors
| Name | Description | 
|---|---|
| PlainTextDocument(file_name) | Creates a plain text document from a file. Automatically detects the file format. | 
| PlainTextDocument(file_name, load_options) | Creates a plain text document from a file. Allows to specify additional options such as an encryption password. | 
| PlainTextDocument(stream) | Creates a plain text document from a stream. Automatically detects the file format. | 
| PlainTextDocument(stream, load_options) | Creates a plain text document from a stream. Allows to specify additional options such as an encryption password. | 
Properties
| Name | Description | 
|---|---|
| built_in_document_properties | Gets PlainTextDocument.built_in_document_properties of the document. | 
| custom_document_properties | Gets PlainTextDocument.custom_document_properties of the document. | 
| text | Gets textual content of the document concatenated as a string. | 
Examples
Shows how to load the contents of a Microsoft Word document in plaintext.
doc = aw.Document()
builder = aw.DocumentBuilder(doc=doc)
builder.writeln('Hello world!')
doc.save(file_name=ARTIFACTS_DIR + 'PlainTextDocument.Load.docx')
plaintext = aw.PlainTextDocument(file_name=ARTIFACTS_DIR + 'PlainTextDocument.Load.docx')
self.assertEqual('Hello world!', plaintext.text.strip())
See Also
- module aspose.words