com.aspose.words
Class PlainTextDocument

java.lang.Object
    extended by com.aspose.words.PlainTextDocument

public class PlainTextDocument 
extends java.lang.Object

Allows to extract plain-text representation of the document's content.

Example:

Shows how to simply extract text from a document.
TxtLoadOptions loadOptions = new TxtLoadOptions();
loadOptions.setDetectNumberingWithWhitespaces(false);

PlainTextDocument plaintext = new PlainTextDocument(getMyDir() + "Document.docx");

plaintext = new PlainTextDocument(getMyDir() + "Document.docx", loadOptions);

Constructor Summary
PlainTextDocument(java.lang.String fileName)
           Creates a plain text document from a file. Automatically detects the file format.
PlainTextDocument(java.lang.String fileName, LoadOptions loadOptions)
           Creates a plain text document from a file. Allows to specify additional options such as an encryption password.
PlainTextDocument(java.io.InputStream stream)
           Creates a plain text document from a stream. Automatically detects the file format.
PlainTextDocument(java.io.InputStream stream, LoadOptions loadOptions)
           Creates a plain text document from a stream. Allows to specify additional options such as an encryption password.
 
Property Getters/Setters Summary
BuiltInDocumentPropertiesgetBuiltInDocumentProperties()
           Gets BuiltInDocumentProperties of the document.
CustomDocumentPropertiesgetCustomDocumentProperties()
           Gets CustomDocumentProperties of the document.
java.lang.StringgetText()
           Gets textual content of the document concatenated as a string.
 

Constructor Detail

PlainTextDocument

public PlainTextDocument(java.lang.String fileName)
                  throws java.lang.Exception
Creates a plain text document from a file. Automatically detects the file format.
Parameters:
fileName - Name of the file to extract the text from.

Example:

Shows how to simply extract text from a document.
TxtLoadOptions loadOptions = new TxtLoadOptions();
loadOptions.setDetectNumberingWithWhitespaces(false);

PlainTextDocument plaintext = new PlainTextDocument(getMyDir() + "Document.docx");

plaintext = new PlainTextDocument(getMyDir() + "Document.docx", loadOptions);

PlainTextDocument

public PlainTextDocument(java.lang.String fileName, LoadOptions loadOptions)
                  throws java.lang.Exception
Creates a plain text document from a file. Allows to specify additional options such as an encryption password.
Parameters:
fileName - Name of the file to extract the text from.
loadOptions - Additional options to use when loading a document. Can be null.

Example:

Shows how to simply extract text from a document.
TxtLoadOptions loadOptions = new TxtLoadOptions();
loadOptions.setDetectNumberingWithWhitespaces(false);

PlainTextDocument plaintext = new PlainTextDocument(getMyDir() + "Document.docx");

plaintext = new PlainTextDocument(getMyDir() + "Document.docx", loadOptions);

PlainTextDocument

public PlainTextDocument(java.io.InputStream stream)
                  throws java.lang.Exception
Creates a plain text document from a stream. Automatically detects the file format.

The document must be stored at the beginning of the stream.

Parameters:
stream - The stream where to extract the text from.

Example:

Shows how to simply extract text from a stream.
TxtLoadOptions loadOptions = new TxtLoadOptions();
loadOptions.setDetectNumberingWithWhitespaces(false);

InputStream stream = new FileInputStream(getMyDir() + "Document.docx");
try
{
    PlainTextDocument plaintext = new PlainTextDocument(stream);
}
finally { if (stream != null) stream.close(); }

PlainTextDocument

public PlainTextDocument(java.io.InputStream stream, LoadOptions loadOptions)
                  throws java.lang.Exception
Creates a plain text document from a stream. Allows to specify additional options such as an encryption password.

The document must be stored at the beginning of the stream.

Parameters:
stream - The stream where to extract the text from.
loadOptions - Additional options to use when loading a document. Can be null.

Property Getters/Setters Detail

getBuiltInDocumentProperties

public BuiltInDocumentProperties getBuiltInDocumentProperties()
Gets BuiltInDocumentProperties of the document.

Example:

Shows how to get BuiltIn properties of plain text document.
PlainTextDocument plaintext = new PlainTextDocument(getMyDir() + "Bookmarks.docx");
BuiltInDocumentProperties builtInDocumentProperties = plaintext.getBuiltInDocumentProperties();

getCustomDocumentProperties

public CustomDocumentProperties getCustomDocumentProperties()
Gets CustomDocumentProperties of the document.

Example:

Shows how to get custom properties of plain text document.
PlainTextDocument plaintext = new PlainTextDocument(getMyDir() + "Bookmarks.docx");
CustomDocumentProperties customDocumentProperties = plaintext.getCustomDocumentProperties();

getText

public java.lang.String getText()
Gets textual content of the document concatenated as a string.

Example:

Shows how to simply extract text from a document.
TxtLoadOptions loadOptions = new TxtLoadOptions();
loadOptions.setDetectNumberingWithWhitespaces(false);

PlainTextDocument plaintext = new PlainTextDocument(getMyDir() + "Document.docx");

plaintext = new PlainTextDocument(getMyDir() + "Document.docx", loadOptions);

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.