This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/web/pdf-generation/from-powerpoint-template.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Generate PDFs from a PowerPoint template using JavaScript | Nutrient Web SDK

Nutrient Web SDK generates documents from PowerPoint templates by merging PPTX files with data. The populated output remains a PPTX file. You can convert it to PDF or PDF/A in the same pipeline.

You can run this flow headlessly or in the Nutrient viewer UI. If your base document is a Word or Excel file, refer to the Word template guide or the Excel template guide. If your base document is already a PDF, refer to the PDF template guide.

This guide covers these tasks:

  • Prepare PPTX templates with placeholders.
  • Populate slides and tables with structured data.
  • Export output as PDF or PDF/A.

General principles

PowerPoint templating uses three inputs:

  • A PPTX file that acts as the template.
  • A template model with placeholder values.
  • Optional delimiter configuration.

populateDocumentTemplate() processes the content of every slide. It returns an ArrayBuffer that contains a populated PPTX file.

Template model

You can define the template model in an external JSON file. You can also build it in code.

The model includes these fields:

  • Optional delimiter configuration with start and end values. The default delimiters are { and }.
  • At least one placeholder-value pair. Placeholder names must match the placeholders in the PPTX template.

Classes, methods, and properties

This guide uses this SDK entry point:

Populate a PowerPoint template

Nutrient Web SDK supports placeholder replacement, loops, conditions, tables, and images in PPTX templates.

Start by preparing a PPTX template with placeholders in the slide content. This example uses {{ and }} delimiters.

Placeholder naming rules

Placeholder names must follow these rules:

  • Simple segments — Avoid whitespace and marker prefix characters, such as #, ^, /, %, and !.
  • Valid examples — {{name}}, {{firstName}}, {{item_1}}, {{TOTAL_AMOUNT}}, and {{company.name}}.
  • Nested values — Use dotted paths, such as {{company.name}}, to reference object values.
  • Literal dots — Use objectDelimiter if a model key contains literal dots.

These rules help the parser read templates and avoid conflicts with special syntax characters.

Prepare data for a presentation title slide:

const data = {
config: {
delimiter: {
start: "{{",
end: "}}",
},
},
model: {
fullName: "Jane Doe",
jobTitle: "Senior Product Designer",
email: "jane.doe@example.com",
phone: "+1 (555) 012-3456",
location: "Berlin, Germany",
summary:
"Product designer with 8+ years of experience leading end-to-end design for B2B SaaS.",
},
};

The template slide contains the matching placeholders:

PowerPoint slide titled Candidate profile with placeholders for the full name, job title, email, phone, location, and summary

Load the PPTX template and replace its placeholders. The method returns an ArrayBuffer with the populated PPTX file:

const buffer = await NutrientViewer.populateDocumentTemplate(
{
// Other configuration options.
document: "title-slide.pptx",
},
data,
);

Next, convert the PPTX file to PDF. This example converts to PDF/A-1a. Choose the conformance value you need from the conformance enumeration.

const pdfBuffer = await NutrientViewer.convertToPDF(
{
// Other configuration options.
document: buffer,
},
NutrientViewer.Conformance.PDFA_1A,
);

If you skip conversion, the populated ArrayBuffer remains a valid PPTX file. Download it directly or load it in the viewer with NutrientViewer.load(). The viewer handles it as an Office document through the standalone conversion pipeline.

Loops

Loops repeat slide content based on arrays in your data model. Use loops for experience lists, agenda items, or feature overviews.

Wrap the repeating content between an opening tag and a closing tag. Place each tag in its own text element on the slide.

For each object in the array, the SDK repeats the content between the tags. It then resolves the placeholders inside that content.

PowerPoint slide titled Experience with the loop opening tag above placeholders for the role, company, period, and description, and the closing tag below

Step one — Prepare your data

Define the array that the loop will repeat:

const data = {
config: {
delimiter: {
start: "{{",
end: "}}",
},
},
model: {
experience: [
{
role: "Lead Product Designer",
company: "Acme Corp",
period: "2021 — Present",
description: "Own the design system and lead a team of 4 designers.",
},
{
role: "Product Designer",
company: "Globex",
period: "2018 — 2021",
description: "Designed the flagship analytics dashboard.",
},
],
},
};

Step two — Generate the populated presentation

Pass the template and model to populateDocumentTemplate():

const buffer = await NutrientViewer.populateDocumentTemplate(
{
// Other configuration options.
document: "presentation.pptx",
},
data,
);

The populated presentation contains one repeated block per entry. It removes all template markers. Loops can be nested to any depth for multilevel data structures.

Table row loops

Tables repeat rows based on arrays in your data model. Use table row loops when each array item needs one table row.

Place the opening tag in the first cell of the table row you want to repeat. Place the closing tag in the last cell of the same row.

For each object in the array, the SDK expands the row with that item’s values.

PowerPoint slide with a pricing table where the header row contains Product, Qty, and Price, and the row below contains the items loop opening tag with the name placeholder, the qty placeholder, and the price placeholder with the closing tag

Use this model:

const data = {
config: {
delimiter: {
start: "{{",
end: "}}",
},
},
model: {
title: "Q3 Product Sales",
showTitle: true,
showSubtitle: false,
items: [
{ name: "Widget A", qty: "120", price: "$1,200" },
{ name: "Widget B", qty: "80", price: "$960" },
{ name: "Gadget C", qty: "45", price: "$2,250" },
],
},
};

The populated table contains one row per item. The slide title renders because showTitle is true.

Add conditional logic

Conditionals insert and remove slide content based on conditions in the template. You can combine conditionals with loops.

Use this syntax:

  • #condition — Starts a block rendered when the condition is true.
  • ^condition — Starts a block rendered when the condition is false.
  • /condition — Ends the conditional block.

This example uses showTitle and showSubtitle in a slide title.

PowerPoint slide with the title text wrapped in a showTitle conditional and the text No subtitle wrapped in an inverse showSubtitle conditional, shown above a pie chart

Combine the template with this data:

{
config: {
delimiter: {
start: "{{",
end: "}}"
}
},
model: {
title: "Q3 Product Sales",
showTitle: true,
showSubtitle: false
}
}

The populated title contains Q3 Product Sales. The inverse showSubtitle block renders No subtitle. Template markers are removed from the output. Conditions are evaluated per slide, so each slide can show or hide its own content from the same model.

Image substitution

NutrientViewer.populateDocumentTemplate() supports image substitution in PPTX templates. You can use image markers with text, loops, and conditionals.

Use these markers in your template:

  • {{%name}} — Inserts an inline image.
  • {{%%name}} — Inserts a centered image.

Set the model entry to an image object with _type: "image":

const data = {
config: {
delimiter: {
start: "{{",
end: "}}",
},
},
model: {
photo: {
_type: "image",
source: "base64",
format: "png",
data: "iVBORw0KGgoAAAANSUhEUg...",
altText: "Profile photo of Jane Doe",
},
},
};

Supported image sources

The source field selects how the image payload is supplied:

  • source: "base64" — Uses the raw Base64 payload in data.
  • source: "dataUrl" — Uses the data URL payload in data as a Base64 alias.
  • source: "url" — Uses the HTTP(S) URL in url and normalizes it at runtime.

For URL sources, the host must enable cross-origin resource sharing (CORS). If the host doesn’t configure CORS, use Base64 or data URL payloads.

Validation and limitations

Review these image constraints before you build your template:

  • For raw Base64 payloads, set format explicitly. For example, use png, jpg, gif, bmp, or tif.
  • source: "file" isn’t supported in browser public APIs.
  • Scalable Vector Graphics (SVG) payloads and SVG formats aren’t supported in this release.
  • If any image entry is invalid or can’t be resolved, the complete templating request fails.

Image entries also support optional properties such as borders, captions, rotation, link targets, and accessibility metadata. For the full list, refer to the populateDocumentTemplate API reference.

Limitations

Review these PowerPoint templating limitations before you build a template:

  • Slide masters aren’t processed. Placeholders in a slide master aren’t replaced.
  • Slide layouts aren’t processed. Placeholders in a slide layout aren’t replaced.
  • Speaker notes aren’t processed. Placeholders in speaker notes aren’t replaced.

Place all placeholders, loops, conditions, tables, and images directly in the content of your slides.

Abort template population

To abort the returned promise for an in-progress populateDocumentTemplate() call, pass an AbortSignal(opens in a new tab) through the signal configuration option. This also works with convertToPDF() in the same pipeline:

const controller = new AbortController();
async function generatePdf() {
const buffer = await NutrientViewer.populateDocumentTemplate(
{
document: "presentation.pptx",
signal: controller.signal,
},
data,
);
const pdfBuffer = await NutrientViewer.convertToPDF(
{
document: buffer,
signal: controller.signal,
},
NutrientViewer.Conformance.PDFA_1A,
);
return pdfBuffer;
}
generatePdf().catch((error) => {
if (error.name === "AbortError") {
console.log("Generation cancelled");
}
});
// Abort the returned promise at any point during the pipeline.
// Underlying processing may continue in the background.
controller.abort();