Alternative way to add footnote to a Google doc programatically

281 Views Asked by At

I am trying to add footnotes programatically to a Google Doc using Google App Script. It appears that such a function does not exist.

The goal is to find abbreviations from a list and insert the footnote that will describe what this abbreviation stands for. The input for the correspondance is a GSheet with one column of abbreviations and one columns of significations. The input data for the text is simply a GDoc with text on it (and title, paragraphs etc.)

I thought of making a python script simulating a user input of shortcuts and text on the GDoc web window, but I would need to also move programatically the cursor in order to put it on the right.

Do you think of any good way of achieving this purpose?

Thanks in advance!

1

There are 1 best solutions below

0
On

From the question

I am trying to add footnotes programatically to a Google Doc using Google App Script. It appears that such a function does not exist.

Documents Service hasn't that method, but the Advanced Document Service has it:

function myFunction() {
  const documentId = DocumentApp.getActiveDocument().getId();
  const requests = [
    {
      createFootnote: {
        location: {
          index: 1
        }
      }
    }
  ]
  Docs.Documents.batchUpdate({requests:requests},documentId)
}

Resource