Skip to content

Text

Add text to slides with full control over formatting.

Basic Text

typescript
slide.addText('Hello World', {
  x: 1, y: 1, w: 8, h: 1.5,
  fontSize: 24,
});
Basic text output
Basic text output

Formatting Options

typescript
slide.addText('Styled Text', {
  x: 1, y: 1, w: 8, h: 1,
  fontSize: 36,
  fontFace: 'Arial',
  color: '003366',
  bold: true,
  italic: true,
  underline: true,
  align: 'center',
});
Styled text output
Styled text output

Paragraph Options

typescript
slide.addText('Spaced text', {
  x: 1, y: 1, w: 8, h: 2,
  lineSpacing: { value: 150, unit: 'pct' },
  spaceBefore: { value: 10, unit: 'pt' },
  spaceAfter: { value: 10, unit: 'pt' },
  align: 'justify',
});

lineSpacing, spaceBefore, and spaceAfter accept either a plain number (treated as the value) or an object { value, unit } where unit is 'pt' (points) or 'pct' (percentage).

Multi-line Text

Newlines in the text string create separate paragraphs:

typescript
slide.addText('Line 1\nLine 2\nLine 3', {
  x: 1, y: 1, w: 8, h: 3,
  fontSize: 18,
});

Bullets & Numbering

typescript
slide.addText('Item one\nItem two\nItem three', {
  x: 1, y: 1, w: 8, h: 2,
  bullet: true,
});

slide.addText('First\nSecond\nThird', {
  x: 1, y: 4, w: 8, h: 2,
  numbering: { type: 'arabicPeriod', startAt: 1 },
});
Bullets and numbering output
Bullets and numbering output

Custom bullet characters:

typescript
slide.addText('Custom bullet', {
  x: 1, y: 1, w: 8, h: 1,
  bullet: { char: '–', color: '4472C4', size: 100 },
});

Vertical Alignment & Text Direction

typescript
slide.addText('Centered vertically', {
  x: 1, y: 1, w: 4, h: 3,
  verticalAlign: 'middle',
  fill: 'F0F0F0',
});

slide.addText('Vertical text', {
  x: 6, y: 1, w: 1, h: 3,
  textDirection: 'vert',
});

Text Body Options

typescript
slide.addText('Auto-shrinking text that fits its container', {
  x: 1, y: 1, w: 4, h: 1,
  autoFit: 'shrink',
  margin: { top: 5, right: 10, bottom: 5, left: 10 },
});
OptionDescription
autoFittrue, 'shrink', or 'none' — controls text overflow
wordWrapEnable/disable word wrapping
marginInner padding { top, right, bottom, left } in points
columnsNumber of text columns
columnSpacingSpace between columns in points

Options Reference

OptionTypeDescription
x, ynumberPosition in inches
w, hnumberSize in inches
fontSizenumberFont size in points
fontFacestringFont family name
colorColorText color (hex string or color object)
boldbooleanBold text
italicbooleanItalic text
underlinebooleanUnderlined text
strikethroughboolean | 'single' | 'double'Strikethrough
alignstring'left', 'center', 'right', 'justify'
verticalAlignstring'top', 'middle', 'bottom'
lineSpacingnumber | { value, unit }Line spacing
spaceBeforenumber | { value, unit }Space before paragraph
spaceAfternumber | { value, unit }Space after paragraph
fillFillText box background
lineLinePropertiesText box border
hyperlinkHyperlinkPropertiesMake text a link

See TextOptions for the full reference.

Released under the MIT License.