Skip to content

Smaller bundles ​

Every entry offers two ways to start a deck. new TsPptx() can author everything the library supports, and a program built on it downloads all of it. createPresentation({ use }) starts from a small core and adds only the construct families you name. A family you do not name is not in your bundle:

ts
import { ChartType, createPresentation } from "pptx-ts"
import { charts } from "pptx-ts/families"

const pres = createPresentation({ use: [charts] })
pres.addSlide().addChart(
  [{ name: "Revenue", labels: ["Q1", "Q2"], values: [1.2, 1.5] }],
  { type: ChartType.bar, x: 1, y: 1, w: 8, h: 4 },
)

For the same calls, both write the same deck, part for part. Families are values rather than strings, so naming one is what puts its code in your program, and a bundler needs no configuration to leave the others out.

What a program downloads ​

Each row is a browser program bundled with esbuild against the current build, minified and gzipped. initial is what the browser fetches before the program's first line runs. total adds every chunk the program can reach later, such as the font parser, which loads only when a font is first registered.

Programinitialtotal
createPresentation(), one text box59.4 KiB138.2 KiB
createPresentation({ use: [charts] }), plus a chart80.5 KiB159.3 KiB
new TsPptx(), one text box98.7 KiB177.4 KiB
new TsPptx(), plus a shape and an image98.9 KiB177.6 KiB
new TsPptx(), plus a chart, a table and a video99.0 KiB177.7 KiB

A text-only program downloads 59.4 KiB composed against 98.7 KiB through the class, so composing saves 39.3 KiB before the first line runs. The chart family costs 21.1 KiB to the program that asks for it and nothing to one that does not. The three TsPptx rows sit within 0.3 KiB of each other, because the class carries every family whatever the program calls.

The comparison page reports 98.6 KiB for a hello world. That is a separate measurement, of a different program, taken with the rest of the comparison on its snapshot date. The figures here come from the repository's size gate and follow the current build; the testing guide describes how both are measured.

The core tier ​

Five families are always composed, so createPresentation() with no argument still writes a deck:

FamilyWhat it authors
texttext boxes
shapespreset shapes, and the rect / line / roundRect descriptors
imagesraster and SVG pictures
groupsaddGroup, and groupObjects over what is already on the slide
notesspeaker notes and the notes slides they are written to

A family is core when leaving it out would make the result something other than a deck. All five are exported from pptx-ts/families too, so you can list one to be explicit; listing it changes nothing.

Everything else is asked for ​

FamilyWhat it authors
chartsevery chart type, with their embedded workbooks. The largest family
tablestables, including tables that continue onto new slides
domTablestableToSlides from a <table> a browser has laid out. Needs a live DOM
mediaembedded and online audio and video
connectorslines drawn between two points or two shapes
oleObjectsembedded OLE objects that travel inside the .pptx
models3dembedded .glb models with their preview picture
zoomsSlide, Section and Summary Zoom tiles
commentsreview comments and the deck-wide author list
animationspreset build animations
measuremeasureText, overflowsBox and tableLayout on the presentation

domTables reads a <table> a browser has already laid out, so it belongs to a program that has a document, and createPresentation from pptx-ts/browser takes it. The DOM-agnostic form of the same conversion is the free tableToSlides on pptx-ts/html, which costs a composed deck nothing.

measure supplies three presentation methods that measure without authoring anything. Text with fit: 'shrink' is still shrunk when the deck is written without it; see Text that fits.

When a family is missing ​

Calling a method whose family you did not compose throws family/not-composed, naming the family, at the call. The method still exists so that the error can say which family to add, rather than TypeError: slide.addChart is not a function.

The types say it first. The slide createPresentation returns carries only the methods your families supply, and each of those methods returns that same slide, so a chain cannot widen back to the full set of methods.

Child descriptors are the one thing the types cannot catch. The { chart: ... }, { image: ... } and { text: ... } forms that a slide master's objects and a group's children use type-check whenever some family claims the key, composed or not. Both walks warn with family/child-not-composed, naming the family to compose. A key no family claims reports group/unrecognized-child, which is usually a typo.