Get the titles of all the slides in a presentation

PowerPoint slide titles are usually represented by placeholder shapes, but real-world files can vary. This simple example treats the first text value found in each slide as that slide's title.

Read slide titles

#![allow(unused)]
fn main() {
pub fn get_slide_titles(path: &Path) -> Result<Vec<String>, Box<dyn std::error::Error>> {
  let titles = get_all_slide_text(path)?
    .into_iter()
    .map(|slide_text| slide_text.into_iter().next().unwrap_or_default())
    .collect();

  Ok(titles)
}
}

The function builds on the all-slide text helper and returns the first text value from each slide, or an empty string when a slide has no text.

When to use a richer title detector

Use this helper for simple extraction and examples. For production title detection, inspect the slide's shape tree and placeholder metadata so that only title placeholders are treated as titles.