Independentsoft
Professional software libraries for developers
Home
Purchase
Support
Company
Contact
JODF
>
Tutorial
> Add annotation
The following example shows how to add an annotation (comment) to a paragraph.
import com.independentsoft.office.odf.Annotation; import com.independentsoft.office.odf.Paragraph; import com.independentsoft.office.odf.TextDocument; import java.util.Calendar; import java.util.Date; public class Example { public static void main(String[] args) { try { TextDocument doc = new TextDocument(); Paragraph commentBody = new Paragraph(); commentBody.add("This is a reviewer comment."); Calendar cal = Calendar.getInstance(); cal.set(2026, Calendar.JANUARY, 15); Date commentDate = cal.getTime(); Annotation annotation = new Annotation(); annotation.setCreator("Jane Smith"); annotation.setCreationDate(commentDate); annotation.setShow(true); annotation.add(commentBody); Paragraph p1 = new Paragraph(); p1.add("This text has an annotation"); p1.add(annotation); p1.add(" attached to it."); doc.getBody().add(p1); doc.save("c:\\test\\output.odt", true); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } }
Need help? Ask our developers:
Name*
Email*
Message*