Text and Hyperlinks

Text is exposed through shape.textFrame.textRange and through table cell text ranges.

const shape = slide.shapes.addTextBox("Revenue improved in Q4", {
  left: 72,
  top: 80,
  width: 520,
  height: 72
});

const text = shape.textFrame.textRange;
text.font.size = 24;
text.font.bold = true;

Text ranges

Use getSubstring to style part of a text frame:

const range = shape.textFrame.textRange;
const q4 = range.getSubstring(20, 2);
q4.font.color = "#1F8A4C";
q4.font.bold = true;

Supported font properties include name, size, color, bold, italic, underline, strikethrough, double strikethrough, all caps, small caps, subscript, and superscript.

Line Breaks

PowerPoint text containing literal carriage-return (CR), line-feed (LF), or CRLF characters renders them as hard line breaks. This applies to loaded text and text written through the Office.js-compatible range APIs.

Paragraph formatting

Paragraph formatting covers horizontal alignment, indent level, and bullet formatting:

const paragraph = shape.textFrame.textRange.paragraphFormat;
paragraph.horizontalAlignment = PowerPoint.ParagraphHorizontalAlignment.center;
paragraph.bulletFormat.visible = true;
paragraph.bulletFormat.type = PowerPoint.BulletType.unnumbered;

Set a hyperlink on a shape or text range:

shape.setHyperlink({ address: "https://docs.witanlabs.com", screenTip: "Docs" });
shape.textFrame.textRange.setHyperlink({ address: "mailto:hello@witanlabs.com" });

Slides and text ranges expose hyperlink collections for inspection and deletion.