1

I'm (very) new to google script (and javascript) and I'm trying to write a script to modify the font size of the footnotes in my document. Unfortunately, there is very little guidance that I can find for interacting with footnotes in a document.

So far I have tried to work from this base, but I get the error

Cannot find function setAttributes in object function getFootnoteContents() {/* */}.

I'm not looking for a "solve this for me answer", just perhaps some pointer as to how to work with the contents of a footnote or somewhere to start the learning process in that direction.

My code is as follows:

function footSize() {
  var doc = DocumentApp.getActiveDocument();
  var footnotes = doc.getFootnotes();
  var style = {};
  style[DocumentApp.Attribute.FONT_SIZE] = 18;
  for(var i in footnotes ){
  Logger.log(footnotes[i].getFootnoteContents.setAttribute(style));
  }
}

SOLUTION using Henrique's answer:

function footSize() {
 var footnote = DocumentApp.getActiveDocument().getFootnotes();
 var style = {};
 style[DocumentApp.Attribute.FONT_SIZE] = 18;
 for(var i in footnote){
   footnote[i].getFootnoteContents().setAttributes(style);
   }
 }
Community
  • 1
  • 1
DavidR
  • 359
  • 1
  • 4
  • 15

1 Answers1

1

getFootnoteContent is a function that retrieves the footnote section so you can manipulate its contents. You could try setting this attribute in the contents (you missed the parenthesis to call the content function) or in the footnote itself.

footnotes[i].setAttribute(style); //or
footnotes[i].getFootnoteContents().setAttribute(style); //note the parenthesis

--to address you edit

After you edited this error would not popup. You're not even referencing getFootnoteContents anymore. If setting the style does not work in the footnote object itself, try setting in its section (2nd suggestion).

Henrique G. Abreu
  • 17,406
  • 3
  • 56
  • 65
  • Thank you! Finally sorted it. – DavidR Feb 08 '16 at 12:13
  • I tried my solution without getFootnoteContents() but the script no longer changed the font size. By the way, do you know how I might change the LINE_SPACING of a footnote using this method? It does not work the same I think because it is an attribute of paragraphs(?) – DavidR Feb 08 '16 at 15:22
  • 1
    I don't DocumentApp that much, but if it's applied to paragraphs you'll have to iterate through the footnote contents section looking for paragraphs and apply the style in each. Take a look [here](http://stackoverflow.com/questions/10692669/how-can-i-generate-a-multipage-text-document-from-a-single-page-template-in-goog/10833393#10833393) on how to iterate a section. – Henrique G. Abreu Feb 10 '16 at 19:04