General

Components

Community

Development

TDF

Documents > Cookbook >TextExtractor



Get Text
TextExtractor provides a method to get the display text of a single element. EditableTextExtractor is a sub class of TextExtractor. It provides a method to return all the text that the user can typically edit in a document, including text in cotent.xml, header and footer in styles.xml, meta data in meta.xml.
The following codes use EditableTextExtractor as an example, the text of the document "textExtractor.odt" is extracted for user. For TextExtractor, it can't extract the text from a TextDocument.

		TextDocument textdoc=(TextDocument)TextDocument.loadDocument("textExtractor.odt");
EditableTextExtractor extractorD = EditableTextExtractor.newOdfEditableTextExtractor(textdoc);
String output = extractorD.getText();
System.out.println(output);

In the following codes, the whole document content will be returned. This operation is the same in TextExtractor.

		OdfElement elem=textdoc.getContentRoot();
EditableTextExtractor extractorE = EditableTextExtractor.newOdfEditableTextExtractor(elem);
System.out.println(extractorE.getText());


Impressum (Legal Info) | Privacy Policy (Datenschutzerklärung) | Statutes (non-binding English translation) - Satzung (binding German version) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Apache License, v2.0. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License v2.0. “LibreOffice” and “The Document Foundation” are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy. LibreOffice was based on OpenOffice.org.