Example: insertBefore method

This example inserts some text at the beginning of the third paragraph.

  TextParagraph paragraph = document.getParagraphs().item(3);
  TextRange range = paragraph.getRange();
  range.insertBefore("the beginning");
  range = paragraph.getRange();
  System.out.println(range.getText());

Related information

insertBefore method