Example: copy method

This example replaces the content of second paragraph with the content of first paragraph.

  TextRange range = document.getParagraphs().item(1).getRange();
  selection.setRange(range.getStart(), range.getEnd());
  selection.copy();
  range = document.getParagraphs().item(2).getRange();
  selection.setRange(range.getStart(), range.getEnd());
  selection.paste();

Related information

copy method

paste method