PPTX Import
Convert PowerPoint files into editable Polotno designs
The @polotno/pptx-import package converts a PowerPoint .pptx file into Polotno design JSON, in the browser or in Node.js. Shapes, text boxes, pictures, tables and 2-D charts arrive as separate, editable elements, never as a flattened slide image.
Importing other formats? See PDF Import, PSD Import and SVG Import for the equivalent packages.
Installation
npm install @polotno/pptx-importIt runs in the browser and in Node.js 22.13 or newer.
Basic Usage
Browser – read bytes from a file input:
import { pptxToJson } from '@polotno/pptx-import';
const file = input.files[0];
const json = await pptxToJson({
pptx: await file.arrayBuffer(),
onWarning: (w) => console.warn(w.code, w.message, w.details),
});
store.loadJSON(json);Node.js – read bytes from disk:
import { readFile } from 'node:fs/promises';
import { pptxToJson } from '@polotno/pptx-import';
const json = await pptxToJson({ pptx: await readFile('./deck.pptx') });pptxToJson takes an ArrayBuffer or Uint8Array and returns a Design Format document, ready for store.loadJSON().
Output
- One page per slide, sized to the slide, in pixels at 96 dpi. A hidden slide is imported too, and its page carries
custom: { pptxHidden: true }. - The master's and layout's own shapes are copied onto every page behind the slide's shapes, unless the slide or layout hides them.
- Pictures, videos, picture backgrounds and embedded fonts are inlined as data URLs, so the design needs nothing else to load. Every element carries its own copy of its picture, so a deck that repeats one picture on many slides imports to a much larger design. To host media yourself, replace the data URLs after the import.
Linked media on a server
A deck can link a picture or video by an http(s) URL. The importer never fetches it, but it goes into the design as the element's src, and whatever renders the design does fetch it. Before you render untrusted decks on a server, check those URLs: they are reported as MEDIA_EXTERNAL warnings.
Fonts
Each font a deck names is resolved in this order:
- A Google Fonts family with the same name.
- A font the deck embeds, unless its licence forbids reuse in an editable design.
- A metric-compatible clone, so lines break where PowerPoint's do: Calibri → Carlito, Cambria → Caladea, Arial and Helvetica → Arimo, Times New Roman → Tinos, Courier New → Cousine.
- Selawik, bundled, for Segoe UI.
- The closest Google Fonts family (Aptos → Inter, Gill Sans → Lato, Futura → Jost, Japanese, Chinese and Korean system fonts → Noto CJK, and more).
- A generic Noto Serif, Roboto Mono or Roboto.
Every substitution is reported once as a FONT_SUBSTITUTED warning. The @polotno/pptx-import README has the full map.
Warnings
The import succeeds when a feature cannot be reproduced exactly: onWarning receives { code, message, details } for every feature approximated or dropped, with the page as details.pageIndex. The codes are FONT_SUBSTITUTED, EMBEDDED_FONT_UNUSABLE, TEXT_FEATURE_UNSUPPORTED, COLOR_TRANSFORM_UNSUPPORTED, IMAGE_UNSUPPORTED, MEDIA_TOO_LARGE, MEDIA_EXTERNAL, OBJECT_PLACEHOLDER, PART_MISSING, FILL_UNSUPPORTED and SHAPE_FEATURE_UNSUPPORTED; the README lists each one's details.
Limitations
- Charts: 2-D bar, column, line, area, scatter, pie and doughnut charts become editable shapes and text. Other chart types import as their fallback picture or a placeholder.
- Text: custom bullet glyphs draw as a disc, and text outlines, highlights, underline colours, custom tab stops and WordArt warps are dropped.
- Animations, transitions and speaker notes are not imported.
- Untrusted uploads: there are no size limits and no zip-bomb guard. A server that accepts public uploads caps its input itself.
Error Handling
A file that cannot be imported rejects with a plain Error whose code is IMPORT_FAILED and whose details are { format: 'pptx', reason }. See Error Handling.
reason | Meaning |
|---|---|
corrupt | Not a valid PPTX package, or a damaged one |
truncated | The file is cut off |
unsupported | A legacy binary .ppt, an unsupported compression method, or no presentation part |
password-required | The PPTX is password-protected; remove the password in PowerPoint first |