# How to View a Document Outline in OfficeCLI: Word and PowerPoint Guide

> Easily view a document outline in Word and PowerPoint using OfficeCLI. Run officecli view "<file>" outline for a hierarchical summary of your documents.

- Repository: [OfficeAI/OfficeCLI](https://github.com/iofficeai/OfficeCLI)
- Tags: how-to-guide
- Published: 2026-07-09

---

**Run `officecli view "<file>" outline` to generate a hierarchical outline of any Word (.docx) or PowerPoint (.pptx) document, with optional JSON output via `--format=json`.**

OfficeCLI provides a unified `view` command that extracts structural outlines from Office documents without opening a GUI. Whether you need to inspect heading hierarchies in Word reports or slide summaries in PowerPoint decks, the CLI renders human-readable outlines directly to stdout. According to the iOfficeAI/OfficeCLI source code, the tool routes outline requests through specialized handlers that parse document internals and return plain-text or JSON representations.

## The View Command Syntax

OfficeCLI exposes outline functionality through the `view` command with the `outline` subcommand. The basic syntax works for both Word and PowerPoint files:

```bash
officecli view "<file-path>" outline

```

For machine-readable output suitable for scripting, append the `--format=json` flag:

```bash
officecli view "<file-path>" outline --format=json

```

The CLI automatically detects the file extension and delegates to the appropriate handler—**`WordHandler`** for `.docx` files or **`PowerPointHandler`** for `.pptx` files.

## How OfficeCLI Generates Document Outlines

The outline generation process follows a centralized routing architecture that delegates to format-specific implementations based on the document type.

### Request Routing via ResidentServer

When you execute the view command, **[`ResidentServer.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/ResidentServer.cs)** receives the request and forwards it to the appropriate handler. As implemented in lines 1718–1763 of [`src/officecli/ResidentServer.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/src/officecli/ResidentServer.cs), the server inspects the file extension and invokes either `ViewAsOutline` for plain text or `ViewAsOutlineJson` when the JSON format flag is present.

### Word Document Outline Generation

For Word documents, the **[`WordHandler.View.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/WordHandler.View.cs)** file (lines 52–87) implements the `ViewAsOutline` method. This handler:

- Collects document statistics including paragraph counts, table counts, image counts, and header/footer information
- Walks the paragraph list and extracts text from paragraphs assigned outline levels via Word styles (Heading 1, Heading 2, etc.)
- Ignores empty paragraphs to maintain a clean hierarchical structure
- Emits a tree view showing heading levels with their corresponding paragraph indices

For JSON output, lines 97–108 implement `ViewAsOutlineJson`, which serializes the same structural data into a machine-readable format.

### PowerPoint Deck Outline Generation

For PowerPoint presentations, **[`PowerPointHandler.View.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/PowerPointHandler.View.cs)** (lines 65–95) handles the outline generation. The `ViewAsOutline` method:

- Enumerates all slide parts in the presentation package
- Extracts each slide’s title text
- Counts content elements including text boxes, pictures, and OLE objects per slide
- Prints a concise summary line for each slide (e.g., "Slide 3: 'Sales Overview' – 2 text box(es), 1 picture")

The handler processes slides sequentially and includes untitled slides in the output, marking them as "(untitled)" when no title shape exists.

## Practical Usage Examples

### Viewing Word Document Outlines

To inspect the heading hierarchy of a Word document:

```bash
officecli view "report.docx" outline

```

Example output:

```text
File: report.docx | 23 paragraphs | 4 tables | 2 images
Header: "Quarterly Review"
Footer: "Page"

├── [1] "Executive Summary" (Heading1)
├── [5] "Market Overview" (Heading1)
│   ├── [6] "North America" (Heading2)
│   └── [9] "Europe" (Heading2)
└── [15] "Recommendations" (Heading1)

```

The output displays paragraph indices in brackets, the heading text, and the style level (Heading1, Heading2, etc.), making it easy to locate specific sections in large documents.

### Viewing PowerPoint Presentation Outlines

To generate an outline of a PowerPoint deck:

```bash
officecli view "deck.pptx" outline

```

Example output:

```text
File: deck.pptx | 12 slides
├── Slide 1: "Title Slide"
├── Slide 2: "Agenda" - 3 text box(es)
├── Slide 5: "Revenue Growth" - 1 picture(s), 2 text box(es)
└── Slide 12: "(untitled)" - 0 text box(es)

```

This format helps you quickly audit slide titles and content density without opening the presentation software.

### Machine-Readable JSON Output

For automation pipelines that need to parse outline data programmatically:

```bash

# Word document JSON outline

officecli view "report.docx" outline --format=json

# PowerPoint JSON outline

officecli view "deck.pptx" outline --format=json

```

The JSON format returns structured data that scripts can consume to extract specific heading levels, slide counts, or content statistics without text parsing.

## Summary

- **Unified command**: Use `officecli view "<file>" outline` for both Word (.docx) and PowerPoint (.pptx) files.
- **Smart routing**: [`ResidentServer.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/ResidentServer.cs) delegates to `WordHandler` or `PowerPointHandler` based on file extension.
- **Implementation details**: Word outlines use style-based heading levels (lines 52–87 of [`WordHandler.View.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/WordHandler.View.cs)), while PowerPoint outlines enumerate slides and count objects (lines 65–95 of [`PowerPointHandler.View.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/PowerPointHandler.View.cs)).
- **Output options**: Default plain-text output provides visual hierarchy; add `--format=json` for structured data suitable for automation.
- **Performance**: Both handlers skip heavy content rendering, focusing only on structural metadata for fast execution.

## Frequently Asked Questions

### What file formats support the outline view in OfficeCLI?

OfficeCLI supports outline generation for **Word documents (.docx)** and **PowerPoint presentations (.pptx)**. The [`ResidentServer.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/ResidentServer.cs) component automatically routes requests to the appropriate handler based on the file extension, ensuring that `.docx` files use the `WordHandler.ViewAsOutline` method and `.pptx` files use `PowerPointHandler.ViewAsOutline`.

### How does OfficeCLI determine heading levels in Word documents?

The [`WordHandler.View.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/WordHandler.View.cs) implementation inspects paragraph styles to determine outline hierarchy. It walks the document's paragraph collection and extracts text from paragraphs assigned outline levels through Word's built-in heading styles (Heading 1, Heading 2, etc.). Empty paragraphs are filtered out to maintain a clean tree view, and each entry shows its paragraph index for easy reference.

### Can I export the outline to JSON format for processing in other tools?

Yes. Append `--format=json` to any outline command to receive structured output. When this flag is present, [`ResidentServer.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/ResidentServer.cs) routes the request to `ViewAsOutlineJson` instead of the standard `ViewAsOutline` method. In [`WordHandler.View.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/WordHandler.View.cs) (lines 97–108) and [`PowerPointHandler.View.cs`](https://github.com/iOfficeAI/OfficeCLI/blob/main/PowerPointHandler.View.cs), these JSON variants serialize the same structural data into machine-readable format suitable for APIs, databases, or configuration management scripts.

### Does the outline view show images and tables in the structure?

The outline view includes **counts** of images and tables in the document statistics header, but it does not list them individually in the hierarchical structure. For Word files, the outline focuses on heading paragraphs only. For PowerPoint files, the outline lists slide titles and counts of text boxes, pictures, and OLE objects per slide, providing a high-level content inventory without extracting full image or table data.