Example: TextParagraph

This example sets red background color for the second paragraph, and inserts some text at the beginning of the paragraph.

import com.ibm.symphony.javaapi.Application;
import com.ibm.symphony.javaapi.Constant;
import com.ibm.symphony.javaapi.document.Document;
import com.ibm.symphony.javaapi.document.Documents;
import com.ibm.symphony.javaapi.document.TextParagraph;
import com.ibm.symphony.javaapi.document.TextRange;

public class TextParagraphExample {

	public void example() {
		try {
			Application application = Application.getInstance();
			Documents documents = application.getDocuments();
			Document document = documents.openDocument("D:\\test.odt", true);
			TextParagraph paragraph = document.getParagraphs().item(2);
			paragraph.setAutoFirstLineIndent(true);
			paragraph.setBackTransparent(false);
			paragraph.setBackgroundColor(application.RGB(255, 0, 0));
			paragraph.setHoriAlignment(Constant.SYMPHONY_TEXT_HORI_ALIGN_LEFT);
			TextRange range = paragraph.getRange();
			range.insertBefore("The beginning");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}

Related information

TextParagraph