text
text
¶
Enumerations related to text in WordprocessingML files.
WD_PARAGRAPH_ALIGNMENT
¶
Bases: BaseXmlEnum
Alias: WD_ALIGN_PARAGRAPH
Specifies paragraph justification type.
Example:
from docx.enum.text import WD_ALIGN_PARAGRAPH
paragraph = document.add_paragraph()
paragraph.alignment = WD_ALIGN_PARAGRAPH.CENTER
CENTER
class-attribute
instance-attribute
¶
Center-aligned.
JUSTIFY
class-attribute
instance-attribute
¶
Fully justified.
DISTRIBUTE
class-attribute
instance-attribute
¶
DISTRIBUTE = (
4,
"distribute",
"Paragraph characters are distributed to fill entire width of paragraph.",
)
Paragraph characters are distributed to fill entire width of paragraph.
JUSTIFY_MED
class-attribute
instance-attribute
¶
Justified with a medium character compression ratio.
JUSTIFY_HI
class-attribute
instance-attribute
¶
Justified with a high character compression ratio.
JUSTIFY_LOW
class-attribute
instance-attribute
¶
Justified with a low character compression ratio.
THAI_JUSTIFY
class-attribute
instance-attribute
¶
Justified according to Thai formatting layout.
WD_BREAK_TYPE
¶
Bases: Enum
Corresponds to WdBreakType enumeration.
http://msdn.microsoft.com/en-us/library/office/ff195905.aspx.
WD_COLOR_INDEX
¶
Bases: BaseXmlEnum
Specifies a standard preset color to apply.
Used for font highlighting and perhaps other applications.
- MS API name:
WdColorIndex - URL: https://msdn.microsoft.com/EN-US/library/office/ff195343.aspx
INHERITED
class-attribute
instance-attribute
¶
Color is inherited from the style hierarchy.
NO_HIGHLIGHT
class-attribute
instance-attribute
¶
Explicitly not highlighted.
Distinct from None, which means no w:highlight element is present and the
highlight is therefore inherited. w:highlight with w:val="none" overrides an
inherited highlight and is written by Word when highlighting is cleared on a run
that sits under a style supplying one.
The MS API assigns wdNoHighlight the value 0, the same value as wdAuto. Two
members cannot share a value here, so this member takes a distinct negative value
in the manner of INHERITED.
AUTO
class-attribute
instance-attribute
¶
Automatic color. Default; usually black.
BRIGHT_GREEN
class-attribute
instance-attribute
¶
Bright green color.
DARK_BLUE
class-attribute
instance-attribute
¶
Dark blue color.
DARK_RED
class-attribute
instance-attribute
¶
Dark red color.
DARK_YELLOW
class-attribute
instance-attribute
¶
Dark yellow color.
GRAY_25
class-attribute
instance-attribute
¶
25% shade of gray color.
GRAY_50
class-attribute
instance-attribute
¶
50% shade of gray color.
TURQUOISE
class-attribute
instance-attribute
¶
Turquoise color.
VIOLET
class-attribute
instance-attribute
¶
Violet color.
WD_CONTENT_CONTROL_TYPE
¶
Bases: BaseEnum
Specifies the kind of a structured document tag (w:sdt), aka content control.
The kind is determined by which child of w:sdtPr is present, not by an attribute
value, so these members have no XML value mapping.
- MS API name:
WdContentControlType - URL: https://learn.microsoft.com/en-us/office/vba/api/word.wdcontentcontroltype
RICH_TEXT
class-attribute
instance-attribute
¶
Formatted text, which may contain multiple paragraphs.
TEXT
class-attribute
instance-attribute
¶
Plain text, a single run without formatting of its own.
COMBO_BOX
class-attribute
instance-attribute
¶
A list of choices that also accepts typed text.
DROPDOWN_LIST
class-attribute
instance-attribute
¶
A list of choices, one of which must be selected.
BUILDING_BLOCK_GALLERY
class-attribute
instance-attribute
¶
A gallery of building blocks, e.g. a cover page.
DATE
class-attribute
instance-attribute
¶
A date, entered through a calendar picker.
GROUP
class-attribute
instance-attribute
¶
A grouping of content that is edited as a unit.
CHECKBOX
class-attribute
instance-attribute
¶
A check box, checked or unchecked.
Written by Word as the w14:checkbox extension element, not as part of the ISO
schema.
REPEATING_SECTION
class-attribute
instance-attribute
¶
A section repeated once per item in a bound collection.
WD_FONT_HINT
¶
Bases: BaseXmlEnum
Specifies which w:rFonts typeface slot Word prefers for ambiguous characters.
A character that belongs to no particular script — a space, a digit, punctuation — could be rendered from more than one slot, and the hint settles it. Getting this wrong is a common cause of East Asian text rendering in the wrong typeface.
There is no MS API enumeration for this; it corresponds to the ST_Hint schema type
and the member values are this library's own.
DEFAULT
class-attribute
instance-attribute
¶
Use the ASCII typeface for ambiguous characters.
EAST_ASIA
class-attribute
instance-attribute
¶
Use the East Asian typeface for ambiguous characters.
COMPLEX_SCRIPT
class-attribute
instance-attribute
¶
Use the complex-script typeface for ambiguous characters.
WD_FORM_FIELD_TYPE
¶
Bases: BaseEnum
Specifies the kind of a legacy form field.
The kind is determined by which child of w:ffData is present, not by an attribute
value, so these members have no XML value mapping.
- MS API name:
WdFieldType(the form-field subset) - URL: https://learn.microsoft.com/en-us/office/vba/api/word.wdfieldtype
WD_LINE_SPACING
¶
Bases: BaseXmlEnum
Specifies a line spacing format to be applied to a paragraph.
Example:
from docx.enum.text import WD_LINE_SPACING
paragraph = document.add_paragraph()
paragraph.line_spacing_rule = WD_LINE_SPACING.EXACTLY
MS API name: WdLineSpacing
URL: http://msdn.microsoft.com/en-us/library/office/ff844910.aspx
SINGLE
class-attribute
instance-attribute
¶
Single spaced (default).
ONE_POINT_FIVE
class-attribute
instance-attribute
¶
Space-and-a-half line spacing.
DOUBLE
class-attribute
instance-attribute
¶
Double spaced.
AT_LEAST
class-attribute
instance-attribute
¶
AT_LEAST = (
3,
"atLeast",
"Minimum line spacing is specified amount. Amount is specified separately.",
)
Minimum line spacing is specified amount. Amount is specified separately.
EXACTLY
class-attribute
instance-attribute
¶
EXACTLY = (
4,
"exact",
"Line spacing is exactly specified amount. Amount is specified separately.",
)
Line spacing is exactly specified amount. Amount is specified separately.
MULTIPLE
class-attribute
instance-attribute
¶
MULTIPLE = (
5,
"auto",
"Line spacing is specified as multiple of line heights. Changing font size will change line spacing proportionately.",
)
Line spacing is specified as multiple of line heights. Changing font size will change the line spacing proportionately.
WD_SHADING_PATTERN
¶
Bases: BaseXmlEnum
Specifies the pattern drawn over the background of shaded content.
The pattern is drawn in the shading color over the shading fill. The common case is CLEAR, which draws no pattern and leaves the fill as a solid background.
- ISO/IEC 29500-1 §17.18.78 (
ST_Shd)
NIL
class-attribute
instance-attribute
¶
No shading. Equivalent to no w:shd element at all.
CLEAR
class-attribute
instance-attribute
¶
No pattern; the fill color forms a solid background.
This is what Word writes for an ordinary background color, and what this library writes when shading is applied without naming a pattern.
SOLID
class-attribute
instance-attribute
¶
The pattern color entirely covers the fill color.
Note the reversal: with SOLID the visible background is the shading color, not the fill.
HORZ_STRIPE
class-attribute
instance-attribute
¶
Horizontal stripes.
VERT_STRIPE
class-attribute
instance-attribute
¶
Vertical stripes.
REVERSE_DIAG_STRIPE
class-attribute
instance-attribute
¶
Diagonal stripes running upward to the right.
DIAG_STRIPE
class-attribute
instance-attribute
¶
Diagonal stripes running downward to the right.
HORZ_CROSS
class-attribute
instance-attribute
¶
A horizontal and vertical crosshatch.
DIAG_CROSS
class-attribute
instance-attribute
¶
A diagonal crosshatch.
THIN_HORZ_STRIPE
class-attribute
instance-attribute
¶
Narrow horizontal stripes.
THIN_VERT_STRIPE
class-attribute
instance-attribute
¶
Narrow vertical stripes.
THIN_REVERSE_DIAG_STRIPE
class-attribute
instance-attribute
¶
THIN_REVERSE_DIAG_STRIPE = (
11,
"thinReverseDiagStripe",
"Narrow diagonal stripes, upward to right.",
)
Narrow diagonal stripes running upward to the right.
THIN_DIAG_STRIPE
class-attribute
instance-attribute
¶
Narrow diagonal stripes running downward to the right.
THIN_HORZ_CROSS
class-attribute
instance-attribute
¶
A narrow horizontal and vertical crosshatch.
THIN_DIAG_CROSS
class-attribute
instance-attribute
¶
A narrow diagonal crosshatch.
PCT_5
class-attribute
instance-attribute
¶
5% of the pattern color over the fill color.
PCT_10
class-attribute
instance-attribute
¶
10% of the pattern color over the fill color.
PCT_12
class-attribute
instance-attribute
¶
12.5% of the pattern color over the fill color.
PCT_15
class-attribute
instance-attribute
¶
15% of the pattern color over the fill color.
PCT_20
class-attribute
instance-attribute
¶
20% of the pattern color over the fill color.
PCT_25
class-attribute
instance-attribute
¶
25% of the pattern color over the fill color.
PCT_30
class-attribute
instance-attribute
¶
30% of the pattern color over the fill color.
PCT_35
class-attribute
instance-attribute
¶
35% of the pattern color over the fill color.
PCT_37
class-attribute
instance-attribute
¶
37.5% of the pattern color over the fill color.
PCT_40
class-attribute
instance-attribute
¶
40% of the pattern color over the fill color.
PCT_45
class-attribute
instance-attribute
¶
45% of the pattern color over the fill color.
PCT_50
class-attribute
instance-attribute
¶
50% of the pattern color over the fill color.
PCT_55
class-attribute
instance-attribute
¶
55% of the pattern color over the fill color.
PCT_60
class-attribute
instance-attribute
¶
60% of the pattern color over the fill color.
PCT_62
class-attribute
instance-attribute
¶
62.5% of the pattern color over the fill color.
PCT_65
class-attribute
instance-attribute
¶
65% of the pattern color over the fill color.
PCT_70
class-attribute
instance-attribute
¶
70% of the pattern color over the fill color.
PCT_75
class-attribute
instance-attribute
¶
75% of the pattern color over the fill color.
PCT_80
class-attribute
instance-attribute
¶
80% of the pattern color over the fill color.
PCT_85
class-attribute
instance-attribute
¶
85% of the pattern color over the fill color.
PCT_87
class-attribute
instance-attribute
¶
87.5% of the pattern color over the fill color.
PCT_90
class-attribute
instance-attribute
¶
90% of the pattern color over the fill color.
PCT_95
class-attribute
instance-attribute
¶
95% of the pattern color over the fill color.
WD_TAB_ALIGNMENT
¶
Bases: BaseXmlEnum
Specifies the tab stop alignment to apply.
MS API name: WdTabAlignment
URL: https://msdn.microsoft.com/EN-US/library/office/ff195609.aspx
CENTER
class-attribute
instance-attribute
¶
Center-aligned.
DECIMAL
class-attribute
instance-attribute
¶
Decimal-aligned.
LIST
class-attribute
instance-attribute
¶
List-aligned. (deprecated)
CLEAR
class-attribute
instance-attribute
¶
Clear an inherited tab stop.
END
class-attribute
instance-attribute
¶
Right-aligned. (deprecated)
NUM
class-attribute
instance-attribute
¶
Left-aligned. (deprecated)
START
class-attribute
instance-attribute
¶
Left-aligned. (deprecated)
WD_TAB_LEADER
¶
Bases: BaseXmlEnum
Specifies the character to use as the leader with formatted tabs.
MS API name: WdTabLeader
URL: https://msdn.microsoft.com/en-us/library/office/ff845050.aspx
WD_TEXT_DIRECTION
¶
Bases: BaseXmlEnum
Specifies the flow direction of text within a paragraph, section or table cell.
This is the writing direction — which way the lines run and whether the glyphs are
rotated — and is a different thing from bidi, which is the base reading direction
of a right-to-left paragraph.
Example:
from docx.enum.text import WD_TEXT_DIRECTION
cell.text_direction = WD_TEXT_DIRECTION.BT_LR # rotated header cell
The names spell out the two axes in the order Word writes them: LR_TB is
left-to-right within a line, top-to-bottom between lines, which is ordinary
horizontal Western layout.
LR_TB
class-attribute
instance-attribute
¶
Horizontal, left to right. Ordinary Western layout.
TB_RL
class-attribute
instance-attribute
¶
Vertical, right to left. Ordinary East Asian vertical layout.
BT_LR
class-attribute
instance-attribute
¶
Rotated 90 degrees counter-clockwise. A rotated table header.
LR_TB_V
class-attribute
instance-attribute
¶
Horizontal, with each glyph rotated 90 degrees clockwise.
TB_RL_V
class-attribute
instance-attribute
¶
Vertical, with each glyph rotated 90 degrees clockwise.
TB_LR_V
class-attribute
instance-attribute
¶
Vertical, left to right, with glyphs rotated.
WD_TEXT_FORM_FIELD_TYPE
¶
Bases: BaseXmlEnum
Specifies what a text form field accepts.
Example:
from docx.enum.text import WD_TEXT_FORM_FIELD_TYPE
form_field.text_type = WD_TEXT_FORM_FIELD_TYPE.NUMBER_TEXT
- MS API name:
WdTextFormFieldType - URL: https://learn.microsoft.com/en-us/office/vba/api/word.wdtextformfieldtype
REGULAR_TEXT
class-attribute
instance-attribute
¶
Any text.
CURRENT_DATE_TEXT
class-attribute
instance-attribute
¶
The current date, filled in by Word.
CURRENT_TIME_TEXT
class-attribute
instance-attribute
¶
The current time, filled in by Word.
CALCULATION_TEXT
class-attribute
instance-attribute
¶
The result of an expression, computed by Word.
WD_UNDERLINE
¶
Bases: BaseXmlEnum
Specifies the style of underline applied to a run of characters.
MS API name: WdUnderline
URL: http://msdn.microsoft.com/en-us/library/office/ff822388.aspx
INHERITED
class-attribute
instance-attribute
¶
Inherit underline setting from containing paragraph.
NONE
class-attribute
instance-attribute
¶
NONE = (
0,
"none",
"No underline.\n\nThis setting overrides any inherited underline value, so can be used to remove underline from a run that inherits underlining from its containing paragraph. Note this is not the same as assigning |None| to Run.underline. |None| is a valid assignment value, but causes the run to inherit its underline value. Assigning `WD_UNDERLINE.NONE` causes underlining to be unconditionally turned off.",
)
No underline.
This setting overrides any inherited underline value, so can be used to remove
underline from a run that inherits underlining from its containing paragraph. Note
this is not the same as assigning None to Run.underline. None is a valid
assignment value, but causes the run to inherit its underline value. Assigning
WD_UNDERLINE.NONE causes underlining to be unconditionally turned off.
SINGLE
class-attribute
instance-attribute
¶
SINGLE = (
1,
"single",
"A single line.\n\nNote that this setting is write-only in the sense that |True| (rather than `WD_UNDERLINE.SINGLE`) is returned for a run having this setting.",
)
A single line.
Note that this setting is write-only in the sense that True
(rather than WD_UNDERLINE.SINGLE) is returned for a run having this setting.
WORDS
class-attribute
instance-attribute
¶
Underline individual words only.
THICK
class-attribute
instance-attribute
¶
A single thick line.
DOT_DASH
class-attribute
instance-attribute
¶
Alternating dots and dashes.
DOT_DOT_DASH
class-attribute
instance-attribute
¶
An alternating dot-dot-dash pattern.
WAVY
class-attribute
instance-attribute
¶
A single wavy line.
DOTTED_HEAVY
class-attribute
instance-attribute
¶
Heavy dots.
DASH_HEAVY
class-attribute
instance-attribute
¶
Heavy dashes.
DOT_DASH_HEAVY
class-attribute
instance-attribute
¶
Alternating heavy dots and heavy dashes.
DOT_DOT_DASH_HEAVY
class-attribute
instance-attribute
¶
An alternating heavy dot-dot-dash pattern.
WAVY_HEAVY
class-attribute
instance-attribute
¶
A heavy wavy line.
DASH_LONG
class-attribute
instance-attribute
¶
Long dashes.
WAVY_DOUBLE
class-attribute
instance-attribute
¶
A double wavy line.
DASH_LONG_HEAVY
class-attribute
instance-attribute
¶
Long heavy dashes.