Google-workspace – Extract slide titles from google slides presentation to create a table of contents

google apigoogle-slidesgoogle-workspace

I need to extract all slide titles from a 100 slide presentation to create a table of contents google document. All the slides follow a strict template so the titles are more or less uniform throughout the presentation.

I am trying to do this using the google slides api–where I can get a json representation of the slide document:

https://slides.googleapis.com/v1/presentations/[presentation id]

But the json seems to be more a collection of shapes and text boxes and it does not seem to trivial to only extract the title text box and its contents.

Does anyone have a way to generate a table of contents automatically or an App script or google slides API way of doing this?

Thanks in advance.
Hari

Best Answer

I wrote an enormous set of code to go through every slide and look through every page element.

CAVEATS:

  • Table of Contents will be based on the first (in order of addition to the slide) text found. If a text box was intended to be the title but was added later than something else with text it will not be used.
  • I have not written code to handle grouped page elements
  • Code will not read alt text for inserted, UNSUPPORTED object types like audio
  • Code does not see anything on the master layouts
  • Text on all other page elements is fair game.

You can add the code to any slide deck but it also lets you look through your drive and select a presentation to add the TOC to. No code is added to that presentation.

https://docs.google.com/presentation/d/1X_zyari_BpEWjJAqnOLrb6rWQvZBvR2wNoBgg5WrgIs/copy

I am very new at coding so perhaps someone else will pick this up and polish it.