_Paragraph
paper-pptx 0.2.0 API reference
Paragraph object. Not intended to be constructed directly.
_Paragraph(p: CT_TextParagraph, parent: ProvidesPart)Attributes
alignment
attributealignmentPP_PARAGRAPH_ALIGNMENT | NoneHorizontal alignment of this paragraph.
The value None indicates the paragraph should 'inherit' its effective value from its
style hierarchy. Assigning None removes any explicit setting, causing its inherited
value to be used.
bullet
attributebulletBulletFormatBulletFormat object providing bullet and numbering control for this paragraph.
paper-pptx addition. Read properties report this paragraph's local a:pPr state only
(None means inherited); setters write real a:buChar/a:buAutoNum/a:buNone
bullets with hanging-indent geometry.
font
attributefontFontFont object containing default character properties for the runs in this paragraph.
These character properties override default properties inherited from parent objects such as the text frame the paragraph is contained in and they may be overridden by character properties set at the run level.
level
attributelevelintIndentation level of this paragraph.
Read-write. Integer in range 0..8 inclusive. 0 represents a top-level paragraph and is the default value. Indentation level is most commonly encountered in a bulleted list, as is found on a word bullet slide.
line_spacing
attributeline_spacingint | float | Length | NoneThe space between baselines in successive lines of this paragraph.
A value of None indicates no explicit value is assigned and its effective value is
inherited from the paragraph's style hierarchy. A numeric value, e.g. 2 or 1.5,
indicates spacing is applied in multiples of line heights. A Length value such as
Pt(12) indicates spacing is a fixed height. The Pt value class is a convenient way to
apply line spacing in units of points.
part
attributepartXmlPartThe package part containing this object.
runs
attributerunstuple[_Run, ...]Sequence of runs in this paragraph.
space_after
attributespace_afterLength | NoneThe spacing to appear between this paragraph and the subsequent paragraph.
A value of None indicates no explicit value is assigned and its effective value is
inherited from the paragraph's style hierarchy. Length objects provide convenience
properties, such as .pt and .inches, that allow easy conversion to various length
units.
space_before
attributespace_beforeLength | NoneThe spacing to appear between this paragraph and the prior paragraph.
A value of None indicates no explicit value is assigned and its effective value is
inherited from the paragraph's style hierarchy. Length objects provide convenience
properties, such as .pt and .cm, that allow easy conversion to various length units.
text
attributetextstrText of paragraph as a single string.
Read/write. This value is formed by concatenating the text in each run and field making up
the paragraph, adding a vertical-tab character ("\v") for each line-break element
(<a:br>, soft carriage-return) encountered.
While the encoding of line-breaks as a vertical tab might be surprising at first, doing so is consistent with PowerPoint's clipboard copy behavior and allows a line-break to be distinguished from a paragraph boundary within the str return value.
Assignment causes all content in the paragraph to be replaced. Each vertical-tab character
("\v") in the assigned str is translated to a line-break, as is each line-feed
character ("\n"). Contrast behavior of line-feed character in TextFrame.text setter.
If line-feed characters are intended to produce new paragraphs, use TextFrame.text
instead. Any other control characters in the assigned string are escaped as a hex
representation like "x001B" (for ESC (ASCII 27) in this example).
Functions
add_datetime_field
funcadd_datetime_field(format_code: str = 'datetime') -> NoneAppend a real date/time field (a:fld type="datetime…") to this paragraph.
paper-pptx addition. format_code is "datetime" or "datetime1" through
"datetime13" (the ECMA-376 date/time field formats); anything else raises
ValueError. The field's cached text is left empty; PowerPoint renders the live
value. Recognized by pptx.inspect.inspect_text via TextBlock.fields.
paramformat_codestr= 'datetime'Returns
Noneadd_line_break
funcadd_line_break()Add line break at end of this paragraph.
add_run
funcadd_run() -> _RunReturn a new run appended to the runs in this paragraph.
Returns
pptx.text.text._Runadd_slide_number_field
funcadd_slide_number_field() -> NoneAppend a real slide-number field (a:fld type="slidenum") to this paragraph.
paper-pptx addition. This is the honest version of typing a literal page
number into a footer: PowerPoint renders the actual slide number and keeps it right
across reordering. The cached text is "1". Recognized by
pptx.inspect.inspect_text via TextBlock.fields.
Returns
Noneclear
funcclear()Remove all content from this paragraph.
Paragraph properties are preserved. Content includes runs, line breaks, and fields.