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.
DocumentAssemblerassembler=newDocumentAssembler();assembler.AssembleDocument(Path.Combine(TemplatesPath,"Image in table cell.pptx"),Path.Combine(OutputPath,"catalogue.pptx"),newDataSourceInfo(newJsonDataSource(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:
LoadSaveOptionsoptions=newLoadSaveOptions(FileFormat.Pdf);options.ResourceLoadBaseUri=TemplatesPath;using(FileStreamtemplate=File.OpenRead(Path.Combine(TemplatesPath,"Image in table cell.pptx")))using(FileStreamreport=File.Create(Path.Combine(OutputPath,"catalogue.pdf"))){assembler.AssembleDocument(template,report,options,newDataSourceInfo(newJsonDataSource(Path.Combine(DataSourcesPath,"products.json")),"products"));}
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.