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

NameDescription
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

NameDescription
built_in_document_propertiesGets PlainTextDocument.built_in_document_properties of the document.
custom_document_propertiesGets PlainTextDocument.custom_document_properties of the document.
textGets 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)
builder.writeln("Hello world!")

doc.save(ARTIFACTS_DIR + "PlainTextDocument.load.docx")

plaintext = aw.PlainTextDocument(ARTIFACTS_DIR + "PlainTextDocument.load.docx")

self.assertEqual("Hello world!", plaintext.text.strip())

See Also