Generate PowerPoint Presentations from JSON

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Assembly MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-assembly -- dnx GroupDocs.Assembly.Mcp --yes
Folders, licensing and more →

A product catalogue, a monthly review, a partner deck: the layout is fixed and the content comes from data. The template stays a .pptx that a designer owns, and nothing in your code knows about slide geometry.

Note
A runnable implementation of this page is on GitHub: powerpoint-decks-from-json-net.

A table that grows, with a picture in every row

One row of the table carries the tags, and the row repeats once per element:

<<foreach [p in products]>><<[p.Name]>>   <<image [p.Photo] -fitHeight>><</foreach>>
[
  { "Name": "Espresso beans, 1 kg", "Photo": "../data/Logo.jpg" },
  { "Name": "Oat milk, 1 l",        "Photo": "../data/no-photo.jpg" }
]
DocumentAssembler assembler = new DocumentAssembler();
assembler.AssembleDocument(
    Path.Combine(TemplatesPath, "Image in table cell.pptx"),
    Path.Combine(OutputPath, "catalogue.pptx"),
    new DataSourceInfo(new JsonDataSource(Path.Combine(DataSourcesPath, "products.json")), "products"));

Two parts of that are new in 26.11.

Note
Images in table cells of presentations and relative image paths are supported since version 26.11.

An <<image>> tag may sit in a table cell of a presentation. The picture becomes the fill of the cell and repeats with the row, including rows produced by foreach. Before, an image in a presentation had to live in its own shape, which does not survive a table that grows. See Insert images dynamically.

The path may be relative. It is resolved against the folder of the template, so the data can carry ../data/Logo.jpg instead of a path that only works on one machine. -fitHeight lets the row grow so the picture keeps its aspect ratio.

Templates read from a stream

A template read from a stream has no folder of its own, so the base for relative paths has to be given explicitly. Forgetting this is the usual reason a working file-based call starts producing empty cells after it is changed to streams:

LoadSaveOptions options = new LoadSaveOptions(FileFormat.Pdf);
options.ResourceLoadBaseUri = TemplatesPath;

using (FileStream template = File.OpenRead(Path.Combine(TemplatesPath, "Image in table cell.pptx")))
using (FileStream report = File.Create(Path.Combine(OutputPath, "catalogue.pdf")))
{
    assembler.AssembleDocument(
        template,
        report,
        options,
        new DataSourceInfo(new JsonDataSource(Path.Combine(DataSourcesPath, "products.json")), "products"));
}

What else a deck template can do

  • Charts built from the data, with series and point colours taken from fields.
  • Bulleted and numbered lists that expand from a collection.
  • Master-detail layouts: a slide section per customer, a row per order.
  • A document table as the data source, when the data arrives as a table inside another presentation or workbook.

Formats

ODP, POTX, PPT and POT templates work the same way as PPTX; the full list is on Supported document formats.

Frequently asked questions

How do you generate a PowerPoint presentation from JSON in C#? Put <<foreach>> tags in one row of a table in a .pptx, point JsonDataSource at the JSON array and call DocumentAssembler.AssembleDocument. The row repeats once per record.

Can an image be placed inside a table cell of a slide? Yes, since version 26.11. The picture becomes the fill of the cell and repeats with the row, including rows produced by foreach.

Can image paths in the data be relative? Yes, resolved against the folder of the template. A template read from a stream has no folder, so set LoadSaveOptions.ResourceLoadBaseUri.

Is Microsoft PowerPoint required on the server? No. The formats are read and written by the library itself.

Which presentation formats can be used as templates? PPTX, PPT, POTX, POT and ODP.