Example: TextSections

This example adds a new section, and sets the second section as the new section's link section.

import com.ibm.symphony.javaapi.Application;
import com.ibm.symphony.javaapi.document.Document;
import com.ibm.symphony.javaapi.document.Documents;
import com.ibm.symphony.javaapi.document.TextSection;
import com.ibm.symphony.javaapi.document.TextSections;

public class TextSectionsExample {

	public void example() {
		try {
			Application application = Application.getInstance();
			Documents documents = application.getDocuments();
			Document document = documents.openDocument(
					"C:\\Scenario\\TextSection.odt", true);
			TextSections sections = document.getSections();
			TextSection section = sections.item(2);
			TextSection newSection = sections.add("New section", document
					.getParagraphs().item(1).getRange(), 1);
			newSection.setLink(section.getName());
			section.setLeftIndent(500);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}

Related information

TextSections