Example: add method

This example adds a graphic object at the end of the second paragraph.

  Application application = Application.getInstance();
  Documents documents = application.getDocuments();
  Document document = documents.openDocument("C:\\graphic.odt", true);
  TextGraphics graphics = document.getTextGraphics();
  TextRange range = document.getParagraphs().item(2).getRange().getEnd();
  TextGraphic graphic = graphics.add("myGraphic", range, "C:\\graphic.jpg");
  graphic.setHeight(5000);
  graphic.setWidth(5000);

Related information

add method