6

I am using the Google Docs API to update content in a document.

The document has a table of contents, but this doesn't update automatically after making changes in the document using the API.

The only method I've found, is to manually open the document and click the refresh icon next to the table of contents, which will update the TOC.

Is there a way to do this programatically, using the Google Docs API?

1

1 Answer 1

7

The Google Docs API does not make available a method that will allow you to automatically refresh the table of contents in a page programmatically. On top of this, without a TableOfContents already in a document, it is currently not possible to obtain links to heading paragraphs, as detailed on Google’s Issue Tracker. This means that elements can not be fetched to insert without manually pressing the refresh button in the document itself.

A feature request to generate and update a Table of Contents programmatically has been submitted here, which you can indicate is a problem you’re also experiencing and get updates by giving it a star.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks very much for this. that makes sense. The only thing is that those issues are from before Google Docs API was released, so I think they must relate to Google Apps Script rather than Google Docs API. I'll put a feature request in for Google Docs API along the same lines.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.