Skip to content

Class: TextFrame ​

Constructors ​

Constructor ​

new TextFrame(txBody, context): TextFrame

Parameters ​

ParameterTypeDescription
txBodyElement-
contextTextContextWhat the frame is read against — its part, the theme, the part's relationships and the inheritance its runs fall back through — handed on to each Paragraph and Run.

Returns ​

TextFrame

Accessors ​

autofit ​

Get Signature ​

get autofit(): AutofitMode | null

The frame's vertical-autofit mode (a:bodyPr autofit child), or null when there is no a:bodyPr. A bodyPr with no autofit child — or an explicit a:noAutofit — reads 'none'. See AutofitMode. This is the deep-model counterpart of inspectPptx's per-shape autofit; unlike the shallow surface it hangs off the navigable text frame.

Returns ​

AutofitMode | null


autofitFontScale ​

Get Signature ​

get autofitFontScale(): number | null

The baked shrink scale of a normAutofit frame as a percent (62.5 = 62.5%), or null when the frame has no a:normAutofit or bakes no scale. A bare <a:normAutofit/> (write-side fit: 'shrink') carries no scale — PowerPoint computes it on edit and draws at 100% until then — so it too reads null; an explicit scale comes from fit: { type: 'shrink', fontScale }.

Returns ​

number | null


autofitLineSpaceReduction ​

Get Signature ​

get autofitLineSpaceReduction(): number | null

The baked line-spacing reduction of a normAutofit frame as a percent (a:normAutofit/@lnSpcReduction ÷ 1000), or null when unset. The companion to autofitFontScale (write-side fit: { type: 'shrink', lnSpcReduction }).

Returns ​

number | null


bodyProperties ​

Get Signature ​

get bodyProperties(): BodyProperties | null

The frame's body properties (a:bodyPr: insets, anchor, vertical text), or null when there is no a:bodyPr. Only explicitly-set insets are reported (a missing side is the PowerPoint default — see BodyProperties).

Returns ​

BodyProperties | null


element_ ​

Get Signature ​

get element_(): Element

Escape hatch: the underlying p:txBody element. After mutating it call markDirty, or save() writes the original bytes.

Returns ​

Element


paragraphs ​

Get Signature ​

get paragraphs(): Paragraph[]

Paragraphs (a:p) in document order.

Returns ​

Paragraph[]


resolvedAnchor ​

Get Signature ​

get resolvedAnchor(): string | null

The effective vertical anchor (t/ctr/b): the frame's own a:bodyPr/@anchor when set, else the anchor it inherits from its layout → master placeholder a:bodyPr. null when nothing in the chain sets one (PowerPoint then defaults to top). Unlike bodyProperties's anchor (own attribute only), this surfaces the inherited anchor a placeholder title relies on — the difference between a top- and centre-anchored title that own-attribute reads alone cannot see.

Returns ​

string | null


text ​

Get Signature ​

get text(): string

All paragraph text joined by \n (mirrors python-pptx TextFrame.text).

Returns ​

string

Set Signature ​

set text(value): void

Replace the frame's text with a single paragraph and run, preserving the character formatting (a:rPr) of the frame's first existing run when there is one. For multiple runs or per-run formatting, edit paragraphs[].runs[] directly.

Parameters ​
ParameterType
valuestring
Returns ​

void

Methods ​

markDirty() ​

markDirty(): void

Mark the owning part dirty so save() reserializes it. Call after mutating element_.

Returns ​

void