---
title: "Generate PDFs from a PowerPoint template using JavaScript | Nutrient Web SDK"
canonical_url: "https://www.nutrient.io/guides/web/pdf-generation/from-powerpoint-template/"
md_url: "https://www.nutrient.io/guides/web/pdf-generation/from-powerpoint-template.md"
last_updated: "2026-08-28T00:00:00.000Z"
description: "Learn to create PDFs from PowerPoint templates using Nutrient Web SDK. Populate PPTX slides and tables with data and export in PDF or PDF/A formats."
---

# Generate PDFs from a PowerPoint template using JavaScript

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](https://www.nutrient.io/guides/web/pdf-generation/from-word-template.md) guide or the [Excel template](https://www.nutrient.io/guides/web/pdf-generation/from-excel-template.md) guide. If your base document is already a PDF, refer to the [PDF template](https://www.nutrient.io/guides/web/pdf-generation/from-pdf-template.md) guide.

[Try for Free](https://www.nutrient.io/sdk/web/getting-started.md)

[Launch Demo](https://www.nutrient.io/demo/office-templating)

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:

- [`NutrientViewer.populateDocumentTemplate`](https://www.nutrient.io/api/web/modules/NutrientViewer.html#.populateDocumentTemplate)

## 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:

```js

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:

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

```js

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](https://www.nutrient.io/api/web/modules/NutrientViewer.html#.Conformance).

```js

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.

**Step one — Prepare your data**

Define the array that the loop will repeat:

```js

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()`:

```js

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.

Use this model:

```js

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.

Combine the template with this data:

```js

{
	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"`:

```js

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](https://www.nutrient.io/api/web/modules/NutrientViewer.html#.populateDocumentTemplate).

## 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`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) through the [`signal`](https://www.nutrient.io/api/web/NutrientViewer.Configuration.html#signal) configuration option. This also works with `convertToPDF()` in the same pipeline:

```js

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();

```
---

## Related pages

- [JavaScript PDF generation library](/guides/web/pdf-generation.md)
- [Angular PDF generation library](/guides/web/pdf-generation/angular.md)
- [ASP.NET PDF generation library](/guides/web/pdf-generation/aspnet.md)
- [Blazor PDF generation library](/guides/web/pdf-generation/blazor.md)
- [Generate PDFs from an Excel template using JavaScript](/guides/web/pdf-generation/from-excel-template.md)
- [Generate PDFs from images using JavaScript](/guides/web/pdf-generation/from-images.md)
- [Generate a PDF with a PDF form using JavaScript](/guides/web/pdf-generation/from-pdf-form.md)
- [Generate PDFs from a template using JavaScript](/guides/web/pdf-generation/from-pdf-template.md)
- [Generate PDFs from a Word template using JavaScript](/guides/web/pdf-generation/from-word-template.md)
- [Headless PDF generation](/guides/web/pdf-generation/headless.md)
- [HTML5 PDF generation library](/guides/web/pdf-generation/html5.md)
- [jQuery PDF generation library](/guides/web/pdf-generation/jquery.md)
- [Next.js PDF generation library](/guides/web/pdf-generation/nextjs.md)
- [Nuxt.js PDF generation library](/guides/web/pdf-generation/nuxtjs.md)
- [Generate PDF reports using JavaScript](/guides/web/pdf-generation/pdf-reports.md)
- [React PDF generation library](/guides/web/pdf-generation/react.md)
- [Svelte PDF generation library](/guides/web/pdf-generation/svelte.md)
- [Generate PDF thumbnails using JavaScript](/guides/web/pdf-generation/thumbnail-preview.md)
- [TypeScript PDF generation library](/guides/web/pdf-generation/typescript.md)
- [Vue.js PDF generation library](/guides/web/pdf-generation/vuejs.md)

