PPTX Import
Import PowerPoint (.pptx) files into your web editor as editable elements with the @polotno/pptx-import JavaScript package, in the browser or Node.js
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, SVG Import, IDML Import and Publisher 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.
- Click links on shapes and on text, and jumps to another slide, become links.
- 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 can succeed when a feature cannot be reproduced exactly. onWarning receives { code, message, details } for approximated or dropped features. Page-specific warnings include details.pageIndex; deck-wide warnings, such as EMBEDDED_FONT_UNUSABLE, omit it. Handle that field as optional.
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.
Round-trip: import, edit, export to PPTX
A deck can be imported, edited in Polotno and written back to .pptx with @polotno/pptx-export:
import { pptxToJson } from '@polotno/pptx-import';
import { jsonToPPTX } from '@polotno/pptx-export';
store.loadJSON(await pptxToJson({ pptx: await file.arrayBuffer() }));
// ...the user edits the design...
await jsonToPPTX(store.toJSON(), 'deck.pptx');The export builds a new deck from the Polotno design. It does not patch the original file. The table is derived from how the two packages work, not from a test on real decks, so check the decks that matter to you in PowerPoint.
| In the original deck | After import and PPTX export |
|---|---|
| Text boxes, with their runs, paragraphs and bullets | Editable PowerPoint text. Custom bullet glyphs are discs, and the text features listed under Limitations are gone |
| Fonts | Font names after the import's substitution. The file embeds no fonts, the deck's own embedded fonts included, so PowerPoint needs them installed |
| Tables | Editable PowerPoint tables. A rotated table is written unrotated |
| Rectangles, rounded rectangles, ellipses, triangles, right triangles and diamonds | Editable PowerPoint shapes when the fill is a solid colour or empty. A triangle, right triangle or diamond with an outline is flattened to a picture, and so is a triangle whose apex is off centre and any shape with a gradient, pattern or soft edge |
| Every other shape, such as stars, arrows and freeform shapes | Flattened to a picture |
| A shape with text inside, and grouped shapes | Separate objects. A shape's text becomes its own text box, and the export writes no groups. A rectangle or rounded rectangle with a solid fill, a plain outline or both, and no effect, usually stays one text shape that draws them |
| Straight lines | Editable PowerPoint lines |
| Pictures | Pictures. Flip, rotation, opacity and shadow are native; a crop, corner radius, border, filter or mask is flattened into the picture |
| Videos | Embedded slide media |
| 2-D bar, column, line, area, scatter, pie and doughnut charts | No longer a PowerPoint chart with data. Bars, straight lines and labels stay editable shapes and text; series lines, areas, markers and pie or doughnut slices are flattened to pictures |
| Other chart types, SmartArt saved without its cached drawing, embedded (OLE) objects, equations, ink | A picture or a placeholder |
| Audio clips | The clip's icon picture. The audio is gone |
| Master and layout shapes | Ordinary shapes on every slide. The import copies them onto each page |
| Click links on shapes and text, and jumps to another slide | PowerPoint hyperlinks and slide jumps |
| Gradient fills and gradient backgrounds | Flattened to a picture |
| Animations, transitions and speaker notes | Gone. They are not imported |
The export side of each row is in the @polotno/pptx-export README, and the import side under Warnings and Limitations.
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 |