0

I'm trying to write up a simple script which will take a footnote added to a Google Document and copy it into an endnotes section. So, the user would use footnotes as normal and then run the script to shift them to the end of the document when they're finished.

I've got a script which returns an array containing [Footnote, Footnote] from my test doc with two included, but I cannot figure out how to convert the object to a string.

function getNotes() {
  var doc = DocumentApp.getActiveDocument().getFootnotes();
  Logger.log(doc);
}

I've pored over the documentation, and I'm really confused because I can't seem to find the getFootnoteContents method mentioned in the Footnotes class. Any direction would be really appreciated.

Rubén
  • 34,714
  • 9
  • 70
  • 166
Brian
  • 4,274
  • 2
  • 27
  • 55

1 Answers1

1

getFootnotes() return an array of footnote objects. You will need to iterate over them to access each one.

function getFootnotes(){
  var doc = DocumentApp.openById('...');
  var footnotes = doc.getFootnotes();
  for(var i in footnotes ){
    Logger.log(footnotes[i].getFootnoteContents().getText());    
  }    
}
Spencer Easton
  • 5,642
  • 1
  • 16
  • 25