docx API Reference
Full documentation for docx (1.2.0)
docx.Document
Python Library Documentation: function Document in module docx.api
Document(docx: 'str | IO[bytes] | None' = None) -> 'DocumentObject'
Return a |Document| object loaded from `docx`, where `docx` can be either a path
to a ``.docx`` file (a string) or a file-like object.
If `docx` is missing or ``None``, the built-in default document "template" is
loaded.
docx.ImagePart
Python Library Documentation: class ImagePart in module docx.parts.image class ImagePart(docx.opc.part.Part) | ImagePart(partname: 'PackURI', content_type: 'str', blob: 'bytes', image: 'Image | None' = None) | | An image part. | | Corresponds to the target part of a relationship with type RELATIONSHIP_TYPE.IMAGE. | | Method resolution order: | ImagePart | docx.opc.part.Part | builtins.object | | Methods defined here: | | __init__(self, partname: 'PackURI', content_type: 'str', blob: 'bytes', image: 'Image | None' = None) | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Class methods defined here: | | from_image(image: 'Image', partname: 'PackURI') | Return an |ImagePart| instance newly created from `image` and assigned | `partname`. | | load(partname: 'PackURI', content_type: 'str', blob: 'bytes', package: 'OpcPackage') | Called by ``docx.opc.package.PartFactory`` to load an image part from a | package being opened by ``Document(...)`` call. | | ---------------------------------------------------------------------- | Readonly properties defined here: | | default_cx | Native width of this image, calculated from its width in pixels and | horizontal dots per inch (dpi). | | default_cy | Native height of this image, calculated from its height in pixels and | vertical dots per inch (dpi). | | filename | Filename from which this image part was originally created. | | A generic name, e.g. 'image.png', is substituted if no name is available, for | example when the image was loaded from an unnamed stream. In that case a default | extension is applied based on the detected MIME type of the image. | | image | | sha1 | SHA1 hash digest of the blob of this image part. | | ---------------------------------------------------------------------- | Methods inherited from docx.opc.part.Part: | | after_unmarshal(self) | Entry point for post-unmarshaling processing, for example to parse the part | XML. | | May be overridden by subclasses without forwarding call to super. | | before_marshal(self) | Entry point for pre-serialization processing, for example to finalize part | naming if necessary. | | May be overridden by subclasses without forwarding call to super. | | drop_rel(self, rId: 'str') | Remove the relationship identified by `rId` if its reference count is less | than 2. | | Relationships with a reference count of 0 are implicit relationships. | | load_rel(self, reltype: 'str', target: 'Part | str', rId: 'str', is_external: 'bool' = False) | Return newly added |_Relationship| instance of `reltype`. | | The new relationship relates the `target` part to this part with key `rId`. | | Target mode is set to ``RTM.EXTERNAL`` if `is_external` is |True|. Intended for | use during load from a serialized package, where the rId is well-known. Other | methods exist for adding a new relationship to a part when manipulating a part. | | part_related_by(self, reltype: 'str') -> 'Part' | Return part to which this part has a relationship of `reltype`. | | Raises |KeyError| if no such relationship is found and |ValueError| if more than | one such relationship is found. Provides ability to resolve implicitly related | part, such as Slide -> SlideLayout. | | relate_to(self, target: 'Part | str', reltype: 'str', is_external: 'bool' = False) -> 'str' | Return rId key of relationship of `reltype` to `target`. | | The returned `rId` is from an existing relationship if there is one, otherwise a | new relationship is created. | | target_ref(self, rId: 'str') -> 'str' | Return URL contained in target ref of relationship identified by `rId`. | | ---------------------------------------------------------------------- | Readonly properties inherited from docx.opc.part.Part: | | blob | Contents of this package part as a sequence of bytes. | | May be text or binary. Intended to be overridden by subclasses. Default behavior | is to return load blob. | | content_type | Content type of this part. | | package | |OpcPackage| instance this part belongs to. | | related_parts | Dictionary mapping related parts by rId, so child objects can resolve | explicit relationships present in the part XML, e.g. sldIdLst to a specific | |Slide| instance. | | ---------------------------------------------------------------------- | Data descriptors inherited from docx.opc.part.Part: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object | | partname | |PackURI| instance holding partname of this part, e.g. | '/ppt/slides/slide1.xml'. | | rels | |Relationships| instance holding the relationships for this part.
docx.RT
Python Library Documentation: class RELATIONSHIP_TYPE in module docx.opc.constants class RELATIONSHIP_TYPE(builtins.object) | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | AUDIO = 'http://schemas.openxmlformats.org/officeDocument/2006/relatio... | | A_F_CHUNK = 'http://schemas.openxmlformats.org/officeDocument/2006/rel... | | CALC_CHAIN = 'http://schemas.openxmlformats.org/officeDocument/2006/re... | | CERTIFICATE = 'http://schemas.openxmlformats.org/package/2006/relation... | | CHART = 'http://schemas.openxmlformats.org/officeDocument/2006/relatio... | | CHARTSHEET = 'http://schemas.openxmlformats.org/officeDocument/2006/re... | | CHART_USER_SHAPES = 'http://schemas.openxmlformats.org/officeDocument/... | | COMMENTS = 'http://schemas.openxmlformats.org/officeDocument/2006/rela... | | COMMENT_AUTHORS = 'http://schemas.openxmlformats.org/officeDocument/20... | | CONNECTIONS = 'http://schemas.openxmlformats.org/officeDocument/2006/r... | | CONTROL = 'http://schemas.openxmlformats.org/officeDocument/2006/relat... | | CORE_PROPERTIES = 'http://schemas.openxmlformats.org/package/2006/rela... | | CUSTOM_PROPERTIES = 'http://schemas.openxmlformats.org/officeDocument/... | | CUSTOM_PROPERTY = 'http://schemas.openxmlformats.org/officeDocument/20... | | CUSTOM_XML = 'http://schemas.openxmlformats.org/officeDocument/2006/re... | | CUSTOM_XML_PROPS = 'http://schemas.openxmlformats.org/officeDocument/2... | | DIAGRAM_COLORS = 'http://schemas.openxmlformats.org/officeDocument/200... | | DIAGRAM_DATA = 'http://schemas.openxmlformats.org/officeDocument/2006/... | | DIAGRAM_LAYOUT = 'http://schemas.openxmlformats.org/officeDocument/200... | | DIAGRAM_QUICK_STYLE = 'http://schemas.openxmlformats.org/officeDocumen... | | DIALOGSHEET = 'http://schemas.openxmlformats.org/officeDocument/2006/r... | | DRAWING = 'http://schemas.openxmlformats.org/officeDocument/2006/relat... | | ENDNOTES = 'http://schemas.openxmlformats.org/officeDocument/2006/rela... | | EXTENDED_PROPERTIES = 'http://schemas.openxmlformats.org/officeDocumen... | | EXTERNAL_LINK = 'http://schemas.openxmlformats.org/officeDocument/2006... | | FONT = 'http://schemas.openxmlformats.org/officeDocument/2006/relation... | | FONT_TABLE = 'http://schemas.openxmlformats.org/officeDocument/2006/re... | | FOOTER = 'http://schemas.openxmlformats.org/officeDocument/2006/relati... | | FOOTNOTES = 'http://schemas.openxmlformats.org/officeDocument/2006/rel... | | GLOSSARY_DOCUMENT = 'http://schemas.openxmlformats.org/officeDocument/... | | HANDOUT_MASTER = 'http://schemas.openxmlformats.org/officeDocument/200... | | HEADER = 'http://schemas.openxmlformats.org/officeDocument/2006/relati... | | HYPERLINK = 'http://schemas.openxmlformats.org/officeDocument/2006/rel... | | IMAGE = 'http://schemas.openxmlformats.org/officeDocument/2006/relatio... | | NOTES_MASTER = 'http://schemas.openxmlformats.org/officeDocument/2006/... | | NOTES_SLIDE = 'http://schemas.openxmlformats.org/officeDocument/2006/r... | | NUMBERING = 'http://schemas.openxmlformats.org/officeDocument/2006/rel... | | OFFICE_DOCUMENT = 'http://schemas.openxmlformats.org/officeDocument/20... | | OLE_OBJECT = 'http://schemas.openxmlformats.org/officeDocument/2006/re... | | ORIGIN = 'http://schemas.openxmlformats.org/package/2006/relationships... | | PACKAGE = 'http://schemas.openxmlformats.org/officeDocument/2006/relat... | | PIVOT_CACHE_DEFINITION = 'http://schemas.openxmlformats.org/officeDocu... | | PIVOT_CACHE_RECORDS = 'http://schemas.openxmlformats.org/officeDocumen... | | PIVOT_TABLE = 'http://schemas.openxmlformats.org/officeDocument/2006/r... | | PRES_PROPS = 'http://schemas.openxmlformats.org/officeDocument/2006/re... | | PRINTER_SETTINGS = 'http://schemas.openxmlformats.org/officeDocument/2... | | QUERY_TABLE = 'http://schemas.openxmlformats.org/officeDocument/2006/r... | | REVISION_HEADERS = 'http://schemas.openxmlformats.org/officeDocument/2... | | REVISION_LOG = 'http://schemas.openxmlformats.org/officeDocument/2006/... | | SETTINGS = 'http://schemas.openxmlformats.org/officeDocument/2006/rela... | | SHARED_STRINGS = 'http://schemas.openxmlformats.org/officeDocument/200... | | SHEET_METADATA = 'http://schemas.openxmlformats.org/officeDocument/200... | | SIGNATURE = 'http://schemas.openxmlformats.org/package/2006/relationsh... | | SLIDE = 'http://schemas.openxmlformats.org/officeDocument/2006/relatio... | | SLIDE_LAYOUT = 'http://schemas.openxmlformats.org/officeDocument/2006/... | | SLIDE_MASTER = 'http://schemas.openxmlformats.org/officeDocument/2006/... | | SLIDE_UPDATE_INFO = 'http://schemas.openxmlformats.org/officeDocument/... | | STYLES = 'http://schemas.openxmlformats.org/officeDocument/2006/relati... | | TABLE = 'http://schemas.openxmlformats.org/officeDocument/2006/relatio... | | TABLE_SINGLE_CELLS = 'http://schemas.openxmlformats.org/officeDocument... | | TABLE_STYLES = 'http://schemas.openxmlformats.org/officeDocument/2006/... | | TAGS = 'http://schemas.openxmlformats.org/officeDocument/2006/relation... | | THEME = 'http://schemas.openxmlformats.org/officeDocument/2006/relatio... | | THEME_OVERRIDE = 'http://schemas.openxmlformats.org/officeDocument/200... | | THUMBNAIL = 'http://schemas.openxmlformats.org/package/2006/relationsh... | | USERNAMES = 'http://schemas.openxmlformats.org/officeDocument/2006/rel... | | VIDEO = 'http://schemas.openxmlformats.org/officeDocument/2006/relatio... | | VIEW_PROPS = 'http://schemas.openxmlformats.org/officeDocument/2006/re... | | VML_DRAWING = 'http://schemas.openxmlformats.org/officeDocument/2006/r... | | VOLATILE_DEPENDENCIES = 'http://schemas.openxmlformats.org/officeDocum... | | WEB_SETTINGS = 'http://schemas.openxmlformats.org/officeDocument/2006/... | | WORKSHEET_SOURCE = 'http://schemas.openxmlformats.org/officeDocument/2... | | XML_MAPS = 'http://schemas.openxmlformats.org/officeDocument/2006/rela...
docx.TYPE_CHECKING
Python Library Documentation: bool object class bool(int) | bool(x) -> bool | | Returns True when the argument x is true, False otherwise. | The builtins True and False are the only two instances of the class bool. | The class bool is a subclass of the class int, and cannot be subclassed. | | Method resolution order: | bool | int | object | | Methods defined here: | | __and__(self, value, /) | Return self&value. | | __invert__(self, /) | ~self | | __or__(self, value, /) | Return self|value. | | __rand__(self, value, /) | Return value&self. | | __repr__(self, /) | Return repr(self). | | __ror__(self, value, /) | Return value|self. | | __rxor__(self, value, /) | Return value^self. | | __xor__(self, value, /) | Return self^value. | | ---------------------------------------------------------------------- | Static methods defined here: | | __new__(*args, **kwargs) | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from int: | | __abs__(self, /) | abs(self) | | __add__(self, value, /) | Return self+value. | | __bool__(self, /) | True if self else False | | __ceil__(...) | Ceiling of an Integral returns itself. | | __divmod__(self, value, /) | Return divmod(self, value). | | __eq__(self, value, /) | Return self==value. | | __float__(self, /) | float(self) | | __floor__(...) | Flooring an Integral returns itself. | | __floordiv__(self, value, /) | Return self//value. | | __format__(self, format_spec, /) | Convert to a string according to format_spec. | | __ge__(self, value, /) | Return self>=value. | | __getattribute__(self, name, /) | Return getattr(self, name). | | __getnewargs__(self, /) | | __gt__(self, value, /) | Return self>value. | | __hash__(self, /) | Return hash(self). | | __index__(self, /) | Return self converted to an integer, if self is suitable for use as an index into a list. | | __int__(self, /) | int(self) | | __le__(self, value, /) | Return self<=value. | | __lshift__(self, value, /) | Return self<<value. | | __lt__(self, value, /) | Return self<value. | | __mod__(self, value, /) | Return self%value. | | __mul__(self, value, /) | Return self*value. | | __ne__(self, value, /) | Return self!=value. | | __neg__(self, /) | -self | | __pos__(self, /) | +self | | __pow__(self, value, mod=None, /) | Return pow(self, value, mod). | | __radd__(self, value, /) | Return value+self. | | __rdivmod__(self, value, /) | Return divmod(value, self). | | __rfloordiv__(self, value, /) | Return value//self. | | __rlshift__(self, value, /) | Return value<<self. | | __rmod__(self, value, /) | Return value%self. | | __rmul__(self, value, /) | Return value*self. | | __round__(...) | Rounding an Integral returns itself. | | Rounding with an ndigits argument also returns an integer. | | __rpow__(self, value, mod=None, /) | Return pow(value, self, mod). | | __rrshift__(self, value, /) | Return value>>self. | | __rshift__(self, value, /) | Return self>>value. | | __rsub__(self, value, /) | Return value-self. | | __rtruediv__(self, value, /) | Return value/self. | | __sizeof__(self, /) | Returns size in memory, in bytes. | | __sub__(self, value, /) | Return self-value. | | __truediv__(self, value, /) | Return self/value. | | __trunc__(...) | Truncating an Integral returns itself. | | as_integer_ratio(self, /) | Return a pair of integers, whose ratio is equal to the original int. | | The ratio is in lowest terms and has a positive denominator. | | >>> (10).as_integer_ratio() | (10, 1) | >>> (-10).as_integer_ratio() | (-10, 1) | >>> (0).as_integer_ratio() | (0, 1) | | bit_count(self, /) | Number of ones in the binary representation of the absolute value of self. | | Also known as the population count. | | >>> bin(13) | '0b1101' | >>> (13).bit_count() | 3 | | bit_length(self, /) | Number of bits necessary to represent self in binary. | | >>> bin(37) | '0b100101' | >>> (37).bit_length() | 6 | | conjugate(...) | Returns self, the complex conjugate of any int. | | is_integer(self, /) | Returns True. Exists for duck type compatibility with float.is_integer. | | to_bytes(self, /, length=1, byteorder='big', *, signed=False) | Return an array of bytes representing an integer. | | length | Length of bytes object to use. An OverflowError is raised if the | integer is not representable with the given number of bytes. Default | is length 1. | byteorder | The byte order used to represent the integer. If byteorder is 'big', | the most significant byte is at the beginning of the byte array. If | byteorder is 'little', the most significant byte is at the end of the | byte array. To request the native byte order of the host system, use | `sys.byteorder' as the byte order value. Default is to use 'big'. | signed | Determines whether two's complement is used to represent the integer. | If signed is False and a negative integer is given, an OverflowError | is raised. | | ---------------------------------------------------------------------- | Class methods inherited from int: | | from_bytes(bytes, byteorder='big', *, signed=False) | Return the integer represented by the given array of bytes. | | bytes | Holds the array of bytes to convert. The argument must either | support the buffer protocol or be an iterable object producing bytes. | Bytes and bytearray are examples of built-in objects that support the | buffer protocol. | byteorder | The byte order used to represent the integer. If byteorder is 'big', | the most significant byte is at the beginning of the byte array. If | byteorder is 'little', the most significant byte is at the end of the | byte array. To request the native byte order of the host system, use | `sys.byteorder' as the byte order value. Default is to use 'big'. | signed | Indicates whether two's complement is used to represent the integer. | | ---------------------------------------------------------------------- | Data descriptors inherited from int: | | denominator | the denominator of a rational number in lowest terms | | imag | the imaginary part of a complex number | | numerator | the numerator of a rational number in lowest terms | | real | the real part of a complex number
docx.Type
Python Library Documentation: _SpecialGenericAlias in module typing
Type = typing.Type
Deprecated alias to builtins.type.
builtins.type or typing.Type can be used to annotate class objects.
For example, suppose we have the following classes::
class User: ... # Abstract base for User classes
class BasicUser(User): ...
class ProUser(User): ...
class TeamUser(User): ...
And a function that takes a class argument that's a subclass of
User and returns an instance of the corresponding class::
def new_user[U](user_class: Type[U]) -> U:
user = user_class()
# (Here we could write the user object to a database)
return user
joe = new_user(BasicUser)
At this point the type checker knows that joe has type BasicUser.
docx.annotations
Python Library Documentation: _Feature in module __future__ object class _Feature(builtins.object) | _Feature(optionalRelease, mandatoryRelease, compiler_flag) | | Methods defined here: | | __init__(self, optionalRelease, mandatoryRelease, compiler_flag) | Initialize self. See help(type(self)) for accurate signature. | | __repr__(self) | Return repr(self). | | getMandatoryRelease(self) | Return release in which this feature will become mandatory. | | This is a 5-tuple, of the same form as sys.version_info, or, if | the feature was dropped, or the release date is undetermined, is None. | | getOptionalRelease(self) | Return first release in which this feature was recognized. | | This is a 5-tuple, of the same form as sys.version_info. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables | | __weakref__ | list of weak references to the object
docx.api
Python Library Documentation: module docx.api in docx
NAME
docx.api - Directly exposed API functions and classes, :func:`Document` for now.
DESCRIPTION
Provides a syntactically more convenient API for interacting with the OpcPackage graph.
FUNCTIONS
Document(docx: 'str | IO[bytes] | None' = None) -> 'DocumentObject'
Return a |Document| object loaded from `docx`, where `docx` can be either a path
to a ``.docx`` file (a string) or a file-like object.
If `docx` is missing or ``None``, the built-in default document "template" is
loaded.
DATA
TYPE_CHECKING = False
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\docx\api.py
docx.blkcntnr
Python Library Documentation: module docx.blkcntnr in docx
NAME
docx.blkcntnr - Block item container, used by body, cell, header, etc.
DESCRIPTION
Block level items are things like paragraph and table, although there are a few other
specialized ones like structured document tags.
CLASSES
docx.shared.StoryChild(builtins.object)
BlockItemContainer
class BlockItemContainer(docx.shared.StoryChild)
| BlockItemContainer(element: 'BlockItemElement', parent: 't.ProvidesStoryPart')
|
| Base class for proxy objects that can contain block items.
|
| These containers include _Body, _Cell, header, footer, footnote, endnote, comment,
| and text box objects. Provides the shared functionality to add a block item like a
| paragraph or table.
|
| Method resolution order:
| BlockItemContainer
| docx.shared.StoryChild
| builtins.object
|
| Methods defined here:
|
| __init__(self, element: 'BlockItemElement', parent: 't.ProvidesStoryPart')
| Initialize self. See help(type(self)) for accurate signature.
|
| add_paragraph(self, text: 'str' = '', style: 'str | ParagraphStyle | None' = None) -> 'Paragraph'
| Return paragraph newly added to the end of the content in this container.
|
| The paragraph has `text` in a single run if present, and is given paragraph
| style `style`.
|
| If `style` is |None|, no paragraph style is applied, which has the same effect
| as applying the 'Normal' style.
|
| add_table(self, rows: 'int', cols: 'int', width: 'Length') -> 'Table'
| Return table of `width` having `rows` rows and `cols` columns.
|
| The table is appended appended at the end of the content in this container.
|
| `width` is evenly distributed between the table columns.
|
| iter_inner_content(self) -> 'Iterator[Paragraph | Table]'
| Generate each `Paragraph` or `Table` in this container in document order.
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| paragraphs
| A list containing the paragraphs in this container, in document order.
|
| Read-only.
|
| tables
| A list containing the tables in this container, in document order.
|
| Read-only.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from docx.shared.StoryChild:
|
| part
| The package part containing this object.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from docx.shared.StoryChild:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
DATA
BlockItemElement = 'CT_Body | CT_Comment | CT_HdrFtr | CT_Tc'
Iterator = typing.Iterator
A generic version of collections.abc.Iterator.
TYPE_CHECKING = False
TypeAlias = typing.TypeAlias
Special form for marking type aliases.
Use TypeAlias to indicate that an assignment should
be recognized as a proper type alias definition by type
checkers.
For example::
Predicate: TypeAlias = Callable[..., bool]
It's invalid when used anywhere except as in the example above.
__annotations__ = {'BlockItemElement': 'TypeAlias'}
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\docx\blkcntnr.py
docx.comments
Python Library Documentation: module docx.comments in docx
NAME
docx.comments - Collection providing access to comments added to this document.
CLASSES
builtins.object
Comments
docx.blkcntnr.BlockItemContainer(docx.shared.StoryChild)
Comment
class Comment(docx.blkcntnr.BlockItemContainer)
| Comment(comment_elm: 'CT_Comment', comments_part: 'CommentsPart')
|
| Proxy for a single comment in the document.
|
| Provides methods to access comment metadata such as author, initials, and date.
|
| A comment is also a block-item container, similar to a table cell, so it can contain both
| paragraphs and tables and its paragraphs can contain rich text, hyperlinks and images,
| although the common case is that a comment contains a single paragraph of plain text like a
| sentence or phrase.
|
| Note that certain content like tables may not be displayed in the Word comment sidebar due to
| space limitations. Such "over-sized" content can still be viewed in the review pane.
|
| Method resolution order:
| Comment
| docx.blkcntnr.BlockItemContainer
| docx.shared.StoryChild
| builtins.object
|
| Methods defined here:
|
| __init__(self, comment_elm: 'CT_Comment', comments_part: 'CommentsPart')
| Initialize self. See help(type(self)) for accurate signature.
|
| add_paragraph(self, text: 'str' = '', style: 'str | ParagraphStyle | None' = None) -> 'Paragraph'
| Return paragraph newly added to the end of the content in this container.
|
| The paragraph has `text` in a single run if present, and is given paragraph style `style`.
| When `style` is |None| or ommitted, the "CommentText" paragraph style is applied, which is
| the default style for comments.
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| comment_id
| The unique identifier of this comment.
|
| text
| The text content of this comment as a string.
|
| Only content in paragraphs is included and of course all emphasis and styling is stripped.
|
| Paragraph boundaries are indicated with a newline (`"\\n"`)
|
| timestamp
| The date and time this comment was authored.
|
| This attribute is optional in the XML, returns |None| if not set.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| author
| Read/write. The recorded author of this comment.
|
| This field is required but can be set to the empty string.
|
| initials
| Read/write. The recorded initials of the comment author.
|
| This attribute is optional in the XML, returns |None| if not set. Assigning |None| removes
| any existing initials from the XML.
|
| ----------------------------------------------------------------------
| Methods inherited from docx.blkcntnr.BlockItemContainer:
|
| add_table(self, rows: 'int', cols: 'int', width: 'Length') -> 'Table'
| Return table of `width` having `rows` rows and `cols` columns.
|
| The table is appended appended at the end of the content in this container.
|
| `width` is evenly distributed between the table columns.
|
| iter_inner_content(self) -> 'Iterator[Paragraph | Table]'
| Generate each `Paragraph` or `Table` in this container in document order.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from docx.blkcntnr.BlockItemContainer:
|
| paragraphs
| A list containing the paragraphs in this container, in document order.
|
| Read-only.
|
| tables
| A list containing the tables in this container, in document order.
|
| Read-only.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from docx.shared.StoryChild:
|
| part
| The package part containing this object.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from docx.shared.StoryChild:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
class Comments(builtins.object)
| Comments(comments_elm: 'CT_Comments', comments_part: 'CommentsPart')
|
| Collection containing the comments added to this document.
|
| Methods defined here:
|
| __init__(self, comments_elm: 'CT_Comments', comments_part: 'CommentsPart')
| Initialize self. See help(type(self)) for accurate signature.
|
| __iter__(self) -> 'Iterator[Comment]'
| Iterator over the comments in this collection.
|
| __len__(self) -> 'int'
| The number of comments in this collection.
|
| add_comment(self, text: 'str' = '', author: 'str' = '', initials: 'str | None' = '') -> 'Comment'
| Add a new comment to the document and return it.
|
| The comment is added to the end of the comments collection and is assigned a unique
| comment-id.
|
| If `text` is provided, it is added to the comment. This option provides for the common
| case where a comment contains a modest passage of plain text. Multiple paragraphs can be
| added using the `text` argument by separating their text with newlines (`"\\n"`).
| Between newlines, text is interpreted as it is in `Document.add_paragraph(text=...)`.
|
| The default is to place a single empty paragraph in the comment, which is the same
| behavior as the Word UI when you add a comment. New runs can be added to the first
| paragraph in the empty comment with `comments.paragraphs[0].add_run()` to adding more
| complex text with emphasis or images. Additional paragraphs can be added using
| `.add_paragraph()`.
|
| `author` is a required attribute, set to the empty string by default.
|
| `initials` is an optional attribute, set to the empty string by default. Passing |None|
| for the `initials` parameter causes that attribute to be omitted from the XML.
|
| get(self, comment_id: 'int') -> 'Comment | None'
| Return the comment identified by `comment_id`, or |None| if not found.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
DATA
Iterator = typing.Iterator
A generic version of collections.abc.Iterator.
TYPE_CHECKING = False
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\docx\comments.py
docx.dml
Python Library Documentation: package docx.dml in docx
NAME
docx.dml
PACKAGE CONTENTS
color
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\docx\dml\__init__.py
docx.document
Python Library Documentation: module docx.document in docx
NAME
docx.document - |Document| and closely related objects.
CLASSES
docx.shared.ElementProxy(builtins.object)
Document
class Document(docx.shared.ElementProxy)
| Document(element: 'CT_Document', part: 'DocumentPart')
|
| WordprocessingML (WML) document.
|
| Not intended to be constructed directly. Use :func:`docx.Document` to open or create
| a document.
|
| Method resolution order:
| Document
| docx.shared.ElementProxy
| builtins.object
|
| Methods defined here:
|
| __init__(self, element: 'CT_Document', part: 'DocumentPart')
| Initialize self. See help(type(self)) for accurate signature.
|
| add_comment(self, runs: 'Run | Sequence[Run]', text: 'str | None' = '', author: 'str' = '', initials: 'str | None' = '') -> 'Comment'
| Add a comment to the document, anchored to the specified runs.
|
| `runs` can be a single `Run` object or a non-empty sequence of `Run` objects. Only the
| first and last run of a sequence are used, it's just more convenient to pass a whole
| sequence when that's what you have handy, like `paragraph.runs` for example. When `runs`
| contains a single `Run` object, that run serves as both the first and last run.
|
| A comment can be anchored only on an even run boundary, meaning the text the comment
| "references" must be a non-zero integer number of consecutive runs. The runs need not be
| _contiguous_ per se, like the first can be in one paragraph and the last in the next
| paragraph, but all runs between the first and the last will be included in the reference.
|
| The comment reference range is delimited by placing a `w:commentRangeStart` element before
| the first run and a `w:commentRangeEnd` element after the last run. This is why only the
| first and last run are required and why a single run can serve as both first and last.
| Word works out which text to highlight in the UI based on these range markers.
|
| `text` allows the contents of a simple comment to be provided in the call, providing for
| the common case where a comment is a single phrase or sentence without special formatting
| such as bold or italics. More complex comments can be added using the returned `Comment`
| object in much the same way as a `Document` or (table) `Cell` object, using methods like
| `.add_paragraph()`, .add_run()`, etc.
|
| The `author` and `initials` parameters allow that metadata to be set for the comment.
| `author` is a required attribute on a comment and is the empty string by default.
| `initials` is optional on a comment and may be omitted by passing |None|, but Word adds an
| `initials` attribute by default and we follow that convention by using the empty string
| when no `initials` argument is provided.
|
| add_heading(self, text: 'str' = '', level: 'int' = 1)
| Return a heading paragraph newly added to the end of the document.
|
| The heading paragraph will contain `text` and have its paragraph style
| determined by `level`. If `level` is 0, the style is set to `Title`. If `level`
| is 1 (or omitted), `Heading 1` is used. Otherwise the style is set to `Heading
| {level}`. Raises |ValueError| if `level` is outside the range 0-9.
|
| add_page_break(self)
| Return newly |Paragraph| object containing only a page break.
|
| add_paragraph(self, text: 'str' = '', style: 'str | ParagraphStyle | None' = None) -> 'Paragraph'
| Return paragraph newly added to the end of the document.
|
| The paragraph is populated with `text` and having paragraph style `style`.
|
| `text` can contain tab (``\t``) characters, which are converted to the
| appropriate XML form for a tab. `text` can also include newline (``\n``) or
| carriage return (``\r``) characters, each of which is converted to a line
| break.
|
| add_picture(self, image_path_or_stream: 'str | IO[bytes]', width: 'int | Length | None' = None, height: 'int | Length | None' = None)
| Return new picture shape added in its own paragraph at end of the document.
|
| The picture contains the image at `image_path_or_stream`, scaled based on
| `width` and `height`. If neither width nor height is specified, the picture
| appears at its native size. If only one is specified, it is used to compute a
| scaling factor that is then applied to the unspecified dimension, preserving the
| aspect ratio of the image. The native size of the picture is calculated using
| the dots-per-inch (dpi) value specified in the image file, defaulting to 72 dpi
| if no value is specified, as is often the case.
|
| add_section(self, start_type: 'WD_SECTION' = <WD_SECTION_START.NEW_PAGE: 2>)
| Return a |Section| object newly added at the end of the document.
|
| The optional `start_type` argument must be a member of the :ref:`WdSectionStart`
| enumeration, and defaults to ``WD_SECTION.NEW_PAGE`` if not provided.
|
| add_table(self, rows: 'int', cols: 'int', style: 'str | _TableStyle | None' = None)
| Add a table having row and column counts of `rows` and `cols` respectively.
|
| `style` may be a table style object or a table style name. If `style` is |None|,
| the table inherits the default table style of the document.
|
| iter_inner_content(self) -> 'Iterator[Paragraph | Table]'
| Generate each `Paragraph` or `Table` in this document in document order.
|
| save(self, path_or_stream: 'str | IO[bytes]')
| Save this document to `path_or_stream`.
|
| `path_or_stream` can be either a path to a filesystem location (a string) or a
| file-like object.
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| comments
| A |Comments| object providing access to comments added to the document.
|
| core_properties
| A |CoreProperties| object providing Dublin Core properties of document.
|
| inline_shapes
| The |InlineShapes| collection for this document.
|
| An inline shape is a graphical object, such as a picture, contained in a run of
| text and behaving like a character glyph, being flowed like other text in a
| paragraph.
|
| paragraphs
| The |Paragraph| instances in the document, in document order.
|
| Note that paragraphs within revision marks such as ``<w:ins>`` or ``<w:del>`` do
| not appear in this list.
|
| part
| The |DocumentPart| object of this document.
|
| sections
| |Sections| object providing access to each section in this document.
|
| settings
| A |Settings| object providing access to the document-level settings.
|
| styles
| A |Styles| object providing access to the styles in this document.
|
| tables
| All |Table| instances in the document, in document order.
|
| Note that only tables appearing at the top level of the document appear in this
| list; a table nested inside a table cell does not appear. A table within
| revision marks such as ``<w:ins>`` or ``<w:del>`` will also not appear in the
| list.
|
| ----------------------------------------------------------------------
| Methods inherited from docx.shared.ElementProxy:
|
| __eq__(self, other: 'object')
| Return |True| if this proxy object refers to the same oxml element as does
| `other`.
|
| ElementProxy objects are value objects and should maintain no mutable local
| state. Equality for proxy objects is defined as referring to the same XML
| element, whether or not they are the same proxy object instance.
|
| __ne__(self, other: 'object')
| Return self!=value.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from docx.shared.ElementProxy:
|
| element
| The lxml element proxied by this object.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from docx.shared.ElementProxy:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from docx.shared.ElementProxy:
|
| __hash__ = None
DATA
Iterator = typing.Iterator
A generic version of collections.abc.Iterator.
List = typing.List
A generic version of list.
Sequence = typing.Sequence
A generic version of collections.abc.Sequence.
TYPE_CHECKING = False
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\docx\document.py
docx.drawing
Python Library Documentation: package docx.drawing in docx
NAME
docx.drawing - DrawingML-related objects are in this subpackage.
PACKAGE CONTENTS
CLASSES
docx.shared.Parented(builtins.object)
Drawing
class Drawing(docx.shared.Parented)
| Drawing(drawing: 'CT_Drawing', parent: 't.ProvidesStoryPart')
|
| Container for a DrawingML object.
|
| Method resolution order:
| Drawing
| docx.shared.Parented
| builtins.object
|
| Methods defined here:
|
| __init__(self, drawing: 'CT_Drawing', parent: 't.ProvidesStoryPart')
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| has_picture
| True when `drawing` contains an embedded picture.
|
| A drawing can contain a picture, but it can also contain a chart, SmartArt, or a
| drawing canvas. Methods related to a picture, like `.image`, will raise when the drawing
| does not contain a picture. Use this value to determine whether image methods will succeed.
|
| This value is `False` when a linked picture is present. This should be relatively rare and
| the image would only be retrievable from the filesystem.
|
| Note this does not distinguish between inline and floating images. The presence of either
| one will cause this value to be `True`.
|
| image
| An `Image` proxy object for the image in this (picture) drawing.
|
| Raises `ValueError` when this drawing does contains something other than a picture. Use
| `.has_picture` to qualify drawing objects before using this property.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from docx.shared.Parented:
|
| part
| The package part containing this object.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from docx.shared.Parented:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
DATA
TYPE_CHECKING = False
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\docx\drawing\__init__.py
docx.enum
Python Library Documentation: package docx.enum in docx
NAME
docx.enum
PACKAGE CONTENTS
base
dml
section
shape
style
table
text
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\docx\enum\__init__.py
docx.exceptions
Python Library Documentation: module docx.exceptions in docx
NAME
docx.exceptions - Exceptions used with python-docx.
DESCRIPTION
The base exception class is PythonDocxError.
CLASSES
builtins.Exception(builtins.BaseException)
PythonDocxError
InvalidSpanError
InvalidXmlError
class InvalidSpanError(PythonDocxError)
| Raised when an invalid merge region is specified in a request to merge table
| cells.
|
| Method resolution order:
| InvalidSpanError
| PythonDocxError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data descriptors inherited from PythonDocxError:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.Exception:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class InvalidXmlError(PythonDocxError)
| Raised when invalid XML is encountered, such as on attempt to access a missing
| required child element.
|
| Method resolution order:
| InvalidXmlError
| PythonDocxError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data descriptors inherited from PythonDocxError:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.Exception:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class PythonDocxError(builtins.Exception)
| Generic error class.
|
| Method resolution order:
| PythonDocxError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data descriptors defined here:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.Exception:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\docx\exceptions.py
docx.image
Python Library Documentation: package docx.image in docx
NAME
docx.image - Provides objects that can characterize image streams.
DESCRIPTION
That characterization is as to content type and size, as a required step in including
them in a document.
PACKAGE CONTENTS
bmp
constants
exceptions
gif
helpers
image
jpeg
png
tiff
DATA
SIGNATURES = ((<class 'docx.image.png.Png'>, 0, b'\x89PNG\r\n\x1a\n'),...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\docx\image\__init__.py
docx.opc
Python Library Documentation: package docx.opc in docx
NAME
docx.opc
PACKAGE CONTENTS
constants
coreprops
exceptions
oxml
package
packuri
part
parts (package)
phys_pkg
pkgreader
pkgwriter
rel
shared
spec
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\docx\opc\__init__.py
docx.oxml
Python Library Documentation: package docx.oxml in docx
NAME
docx.oxml - Initializes oxml sub-package.
DESCRIPTION
This including registering custom element classes corresponding to Open XML elements.
PACKAGE CONTENTS
comments
coreprops
document
drawing
exceptions
ns
numbering
parser
section
settings
shape
shared
simpletypes
styles
table
text (package)
xmlchemy
FUNCTIONS
OxmlElement(nsptag_str: 'str', attrs: 'Dict[str, str] | None' = None, nsdecls: 'Dict[str, str] | None' = None) -> 'BaseOxmlElement | etree._Element'
Return a 'loose' lxml element having the tag specified by `nsptag_str`.
The tag in `nsptag_str` must contain the standard namespace prefix, e.g. `a:tbl`.
The resulting element is an instance of the custom element class for this tag name
if one is defined. A dictionary of attribute values may be provided as `attrs`; they
are set if present. All namespaces defined in the dict `nsdecls` are declared in the
element using the key as the prefix and the value as the namespace name. If
`nsdecls` is not provided, a single namespace declaration is added based on the
prefix on `nsptag_str`.
parse_xml(xml: 'str | bytes') -> "'BaseOxmlElement'"
Root lxml element obtained by parsing XML character string `xml`.
The custom parser is used, so custom element classes are produced for elements in
`xml` that have them.
DATA
__all__ = ['OxmlElement', 'parse_xml']
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\docx\oxml\__init__.py
docx.package
Python Library Documentation: module docx.package in docx
NAME
docx.package - WordprocessingML Package class and related objects.
CLASSES
builtins.object
ImageParts
docx.opc.package.OpcPackage(builtins.object)
Package
class ImageParts(builtins.object)
| Collection of |ImagePart| objects corresponding to images in the package.
|
| Methods defined here:
|
| __contains__(self, item: 'object')
|
| __init__(self)
| Initialize self. See help(type(self)) for accurate signature.
|
| __iter__(self)
|
| __len__(self)
|
| append(self, item: 'ImagePart')
|
| get_or_add_image_part(self, image_descriptor: 'str | IO[bytes]') -> 'ImagePart'
| Return |ImagePart| object containing image identified by `image_descriptor`.
|
| The image-part is newly created if a matching one is not present in the
| collection.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
class Package(docx.opc.package.OpcPackage)
| Customizations specific to a WordprocessingML package.
|
| Method resolution order:
| Package
| docx.opc.package.OpcPackage
| builtins.object
|
| Methods defined here:
|
| after_unmarshal(self)
| Called by loading code after all parts and relationships have been loaded.
|
| This method affords the opportunity for any required post-processing.
|
| get_or_add_image_part(self, image_descriptor: 'str | IO[bytes]') -> 'ImagePart'
| Return |ImagePart| containing image specified by `image_descriptor`.
|
| The image-part is newly created if a matching one is not already present in the
| collection.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| image_parts
| |ImageParts| collection object for this package.
|
| ----------------------------------------------------------------------
| Methods inherited from docx.opc.package.OpcPackage:
|
| iter_parts(self) -> 'Iterator[Part]'
| Generate exactly one reference to each of the parts in the package by
| performing a depth-first traversal of the rels graph.
|
| iter_rels(self) -> 'Iterator[_Relationship]'
| Generate exactly one reference to each relationship in the package by
| performing a depth-first traversal of the rels graph.
|
| load_rel(self, reltype: 'str', target: 'Part | str', rId: 'str', is_external: 'bool' = False)
| Return newly added |_Relationship| instance of `reltype` between this part
| and `target` with key `rId`.
|
| Target mode is set to ``RTM.EXTERNAL`` if `is_external` is |True|. Intended for
| use during load from a serialized package, where the rId is well known. Other
| methods exist for adding a new relationship to the package during processing.
|
| next_partname(self, template: 'str') -> 'PackURI'
| Return a |PackURI| instance representing partname matching `template`.
|
| The returned part-name has the next available numeric suffix to distinguish it
| from other parts of its type. `template` is a printf (%)-style template string
| containing a single replacement item, a '%d' to be used to insert the integer
| portion of the partname. Example: "/word/header%d.xml"
|
| part_related_by(self, reltype: 'str') -> 'Part'
| Return part to which this package has a relationship of `reltype`.
|
| Raises |KeyError| if no such relationship is found and |ValueError| if more than
| one such relationship is found.
|
| relate_to(self, part: 'Part', reltype: 'str')
| Return rId key of new or existing relationship to `part`.
|
| If a relationship of `reltype` to `part` already exists, its rId is returned. Otherwise a
| new relationship is created and that rId is returned.
|
| save(self, pkg_file: 'str | IO[bytes]')
| Save this package to `pkg_file`.
|
| `pkg_file` can be either a file-path or a file-like object.
|
| ----------------------------------------------------------------------
| Class methods inherited from docx.opc.package.OpcPackage:
|
| open(pkg_file: 'str | IO[bytes]') -> 'Self'
| Return an |OpcPackage| instance loaded with the contents of `pkg_file`.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from docx.opc.package.OpcPackage:
|
| core_properties
| |CoreProperties| object providing read/write access to the Dublin Core
| properties for this document.
|
| main_document_part
| Return a reference to the main document part for this package.
|
| Examples include a document part for a WordprocessingML package, a presentation
| part for a PresentationML package, or a workbook part for a SpreadsheetML
| package.
|
| parts
| Return a list containing a reference to each of the parts in this package.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from docx.opc.package.OpcPackage:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| rels
| Return a reference to the |Relationships| instance holding the collection of
| relationships for this package.
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\docx\package.py
docx.parts
Python Library Documentation: package docx.parts in docx
NAME
docx.parts
PACKAGE CONTENTS
comments
document
hdrftr
image
numbering
settings
story
styles
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\docx\parts\__init__.py
docx.section
Python Library Documentation: module docx.section in docx
NAME
docx.section - The |Section| object and related proxy classes.
CLASSES
builtins.object
Section
collections.abc.Sequence(collections.abc.Reversible, collections.abc.Collection)
Sections(collections.abc.Sequence, typing.Generic)
typing.Generic(builtins.object)
Sections(collections.abc.Sequence, typing.Generic)
class Section(builtins.object)
| Section(sectPr: 'CT_SectPr', document_part: 'DocumentPart')
|
| Document section, providing access to section and page setup settings.
|
| Also provides access to headers and footers.
|
| Methods defined here:
|
| __init__(self, sectPr: 'CT_SectPr', document_part: 'DocumentPart')
| Initialize self. See help(type(self)) for accurate signature.
|
| iter_inner_content(self) -> 'Iterator[Paragraph | Table]'
| Generate each Paragraph or Table object in this `section`.
|
| Items appear in document order.
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| even_page_footer
| |_Footer| object defining footer content for even pages.
|
| The content of this footer definition is ignored unless the document setting
| :attr:`~.Settings.odd_and_even_pages_header_footer` is set True.
|
| even_page_header
| |_Header| object defining header content for even pages.
|
| The content of this header definition is ignored unless the document setting
| :attr:`~.Settings.odd_and_even_pages_header_footer` is set True.
|
| first_page_footer
| |_Footer| object defining footer content for the first page of this section.
|
| The content of this footer definition is ignored unless the property
| :attr:`.different_first_page_header_footer` is set True.
|
| first_page_header
| |_Header| object defining header content for the first page of this section.
|
| The content of this header definition is ignored unless the property
| :attr:`.different_first_page_header_footer` is set True.
|
| part
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| bottom_margin
| Read/write. Bottom margin for pages in this section, in EMU.
|
| `None` when no bottom margin has been specified. Assigning |None| removes any
| bottom-margin setting.
|
| different_first_page_header_footer
| True if this section displays a distinct first-page header and footer.
|
| Read/write. The definition of the first-page header and footer are accessed
| using :attr:`.first_page_header` and :attr:`.first_page_footer` respectively.
|
| footer
| |_Footer| object representing default page footer for this section.
|
| The default footer is used for odd-numbered pages when separate odd/even footers
| are enabled. It is used for both odd and even-numbered pages otherwise.
|
| footer_distance
| Distance from bottom edge of page to bottom edge of the footer.
|
| Read/write. |None| if no setting is present in the XML.
|
| gutter
| |Length| object representing page gutter size in English Metric Units.
|
| Read/write. The page gutter is extra spacing added to the `inner` margin to
| ensure even margins after page binding. Generally only used in book-bound
| documents with double-sided and facing pages.
|
| This setting applies to all pages in this section.
|
| header
| |_Header| object representing default page header for this section.
|
| The default header is used for odd-numbered pages when separate odd/even headers
| are enabled. It is used for both odd and even-numbered pages otherwise.
|
| header_distance
| Distance from top edge of page to top edge of header.
|
| Read/write. |None| if no setting is present in the XML. Assigning |None| causes
| default value to be used.
|
| left_margin
| |Length| object representing the left margin for all pages in this section in
| English Metric Units.
|
| orientation
| :ref:`WdOrientation` member specifying page orientation for this section.
|
| One of ``WD_ORIENT.PORTRAIT`` or ``WD_ORIENT.LANDSCAPE``.
|
| page_height
| Total page height used for this section.
|
| This value is inclusive of all edge spacing values such as margins.
|
| Page orientation is taken into account, so for example, its expected value
| would be ``Inches(8.5)`` for letter-sized paper when orientation is landscape.
|
| page_width
| Total page width used for this section.
|
| This value is like "paper size" and includes all edge spacing values such as
| margins.
|
| Page orientation is taken into account, so for example, its expected value
| would be ``Inches(11)`` for letter-sized paper when orientation is landscape.
|
| right_margin
| |Length| object representing the right margin for all pages in this section
| in English Metric Units.
|
| start_type
| Type of page-break (if any) inserted at the start of this section.
|
| For exmple, ``WD_SECTION_START.ODD_PAGE`` if the section should begin on the
| next odd page, possibly inserting two page-breaks instead of one.
|
| top_margin
| |Length| object representing the top margin for all pages in this section in
| English Metric Units.
class Sections(collections.abc.Sequence, typing.Generic)
| Sections(document_elm: 'CT_Document', document_part: 'DocumentPart')
|
| Sequence of |Section| objects corresponding to the sections in the document.
|
| Supports ``len()``, iteration, and indexed access.
|
| Method resolution order:
| Sections
| collections.abc.Sequence
| collections.abc.Reversible
| collections.abc.Collection
| collections.abc.Sized
| collections.abc.Iterable
| collections.abc.Container
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| __getitem__(self, key: 'int | slice') -> 'Section | List[Section]'
|
| __init__(self, document_elm: 'CT_Document', document_part: 'DocumentPart')
| Initialize self. See help(type(self)) for accurate signature.
|
| __iter__(self) -> 'Iterator[Section]'
|
| __len__(self) -> 'int'
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __orig_bases__ = (typing.Sequence[docx.section.Section],)
|
| __parameters__ = ()
|
| ----------------------------------------------------------------------
| Methods inherited from collections.abc.Sequence:
|
| __contains__(self, value)
|
| __reversed__(self)
|
| count(self, value)
| S.count(value) -> integer -- return number of occurrences of value
|
| index(self, value, start=0, stop=None)
| S.index(value, [start, [stop]]) -> integer -- return first index of value.
| Raises ValueError if the value is not present.
|
| Supporting start and stop arguments is optional, but
| recommended.
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Reversible:
|
| __subclasshook__(C)
| Abstract classes can override this to customize issubclass().
|
| This is invoked early on by abc.ABCMeta.__subclasscheck__().
| It should return True, False or NotImplemented. If it returns
| NotImplemented, the normal algorithm is used. Otherwise, it
| overrides the normal algorithm (and the outcome is cached).
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Iterable:
|
| __class_getitem__ = GenericAlias(...)
| Represent a PEP 585 generic type
|
| E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __init_subclass__(...)
| Function to initialize subclasses.
DATA
Iterator = typing.Iterator
A generic version of collections.abc.Iterator.
List = typing.List
A generic version of list.
Sequence = typing.Sequence
A generic version of collections.abc.Sequence.
TYPE_CHECKING = False
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\docx\section.py
docx.settings
Python Library Documentation: module docx.settings in docx
NAME
docx.settings - Settings object, providing access to document-level settings.
CLASSES
docx.shared.ElementProxy(builtins.object)
Settings
class Settings(docx.shared.ElementProxy)
| Settings(element: 'BaseOxmlElement', parent: 't.ProvidesXmlPart | None' = None)
|
| Provides access to document-level settings for a document.
|
| Accessed using the :attr:`.Document.settings` property.
|
| Method resolution order:
| Settings
| docx.shared.ElementProxy
| builtins.object
|
| Methods defined here:
|
| __init__(self, element: 'BaseOxmlElement', parent: 't.ProvidesXmlPart | None' = None)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| odd_and_even_pages_header_footer
| True if this document has distinct odd and even page headers and footers.
|
| Read/write.
|
| ----------------------------------------------------------------------
| Methods inherited from docx.shared.ElementProxy:
|
| __eq__(self, other: 'object')
| Return |True| if this proxy object refers to the same oxml element as does
| `other`.
|
| ElementProxy objects are value objects and should maintain no mutable local
| state. Equality for proxy objects is defined as referring to the same XML
| element, whether or not they are the same proxy object instance.
|
| __ne__(self, other: 'object')
| Return self!=value.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from docx.shared.ElementProxy:
|
| element
| The lxml element proxied by this object.
|
| part
| The package part containing this object.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from docx.shared.ElementProxy:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from docx.shared.ElementProxy:
|
| __hash__ = None
DATA
TYPE_CHECKING = False
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\docx\settings.py
docx.shape
Python Library Documentation: module docx.shape in docx
NAME
docx.shape - Objects related to shapes.
DESCRIPTION
A shape is a visual object that appears on the drawing layer of a document.
CLASSES
builtins.object
InlineShape
docx.shared.Parented(builtins.object)
InlineShapes
class InlineShape(builtins.object)
| InlineShape(inline: 'CT_Inline')
|
| Proxy for an ``<wp:inline>`` element, representing the container for an inline
| graphical object.
|
| Methods defined here:
|
| __init__(self, inline: 'CT_Inline')
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| type
| The type of this inline shape as a member of
| ``docx.enum.shape.WD_INLINE_SHAPE``, e.g. ``LINKED_PICTURE``.
|
| Read-only.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| height
| Read/write.
|
| The display height of this inline shape as an |Emu| instance.
|
| width
| Read/write.
|
| The display width of this inline shape as an |Emu| instance.
class InlineShapes(docx.shared.Parented)
| InlineShapes(body_elm: 'CT_Body', parent: 'StoryPart')
|
| Sequence of |InlineShape| instances, supporting len(), iteration, and indexed access.
|
| Method resolution order:
| InlineShapes
| docx.shared.Parented
| builtins.object
|
| Methods defined here:
|
| __getitem__(self, idx: 'int')
| Provide indexed access, e.g. 'inline_shapes[idx]'.
|
| __init__(self, body_elm: 'CT_Body', parent: 'StoryPart')
| Initialize self. See help(type(self)) for accurate signature.
|
| __iter__(self)
|
| __len__(self)
|
| ----------------------------------------------------------------------
| Readonly properties inherited from docx.shared.Parented:
|
| part
| The package part containing this object.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from docx.shared.Parented:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
DATA
TYPE_CHECKING = False
nsmap = {'a': 'http://schemas.openxmlformats.org/drawingml/2006/main',...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\docx\shape.py
docx.styles
Python Library Documentation: package docx.styles in docx
NAME
docx.styles - Sub-package module for docx.styles sub-package.
PACKAGE CONTENTS
latent
style
styles
CLASSES
builtins.object
BabelFish
class BabelFish(builtins.object)
| Translates special-case style names from UI name (e.g. Heading 1) to
| internal/styles.xml name (e.g. heading 1) and back.
|
| Class methods defined here:
|
| internal2ui(internal_style_name: 'str') -> 'str'
| Return the user interface style name corresponding to `internal_style_name`,
| such as 'Heading 1' for 'heading 1'.
|
| ui2internal(ui_style_name: 'str') -> 'str'
| Return the internal style name corresponding to `ui_style_name`, such as
| 'heading 1' for 'Heading 1'.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {'internal_style_names': 'Dict[str, str]'}
|
| internal_style_names = {'Caption': 'caption', 'Footer': 'footer', 'Hea...
|
| style_aliases = (('Caption', 'caption'), ('Footer', 'footer'), ('Heade...
|
| ui_style_names = {'caption': 'Caption', 'footer': 'Footer', 'header': ...
DATA
Dict = typing.Dict
A generic version of dict.
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\docx\styles\__init__.py
docx.table
Python Library Documentation: module docx.table in docx
NAME
docx.table - The |Table| object and related proxy classes.
CLASSES
docx.shared.StoryChild(builtins.object)
Table
class Table(docx.shared.StoryChild)
| Table(tbl: 'CT_Tbl', parent: 't.ProvidesStoryPart')
|
| Proxy class for a WordprocessingML ``<w:tbl>`` element.
|
| Method resolution order:
| Table
| docx.shared.StoryChild
| builtins.object
|
| Methods defined here:
|
| __init__(self, tbl: 'CT_Tbl', parent: 't.ProvidesStoryPart')
| Initialize self. See help(type(self)) for accurate signature.
|
| add_column(self, width: 'Length')
| Return a |_Column| object of `width`, newly added rightmost to the table.
|
| add_row(self)
| Return a |_Row| instance, newly added bottom-most to the table.
|
| cell(self, row_idx: 'int', col_idx: 'int') -> '_Cell'
| |_Cell| at `row_idx`, `col_idx` intersection.
|
| (0, 0) is the top, left-most cell.
|
| column_cells(self, column_idx: 'int') -> 'list[_Cell]'
| Sequence of cells in the column at `column_idx` in this table.
|
| row_cells(self, row_idx: 'int') -> 'list[_Cell]'
| DEPRECATED: Use `table.rows[row_idx].cells` instead.
|
| Sequence of cells in the row at `row_idx` in this table.
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| table
| Provide child objects with reference to the |Table| object they belong to,
| without them having to know their direct parent is a |Table| object.
|
| This is the terminus of a series of `parent._table` calls from an arbitrary
| child through its ancestors.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| alignment
| Read/write.
|
| A member of :ref:`WdRowAlignment` or None, specifying the positioning of this
| table between the page margins. |None| if no setting is specified, causing the
| effective value to be inherited from the style hierarchy.
|
| autofit
| |True| if column widths can be automatically adjusted to improve the fit of
| cell contents.
|
| |False| if table layout is fixed. Column widths are adjusted in either case if
| total column width exceeds page width. Read/write boolean.
|
| columns
| |_Columns| instance representing the sequence of columns in this table.
|
| rows
| |_Rows| instance containing the sequence of rows in this table.
|
| style
| |_TableStyle| object representing the style applied to this table.
|
| Read/write. The default table style for the document (often `Normal Table`) is
| returned if the table has no directly-applied style. Assigning |None| to this
| property removes any directly-applied table style causing it to inherit the
| default table style of the document.
|
| Note that the style name of a table style differs slightly from that displayed
| in the user interface; a hyphen, if it appears, must be removed. For example,
| `Light Shading - Accent 1` becomes `Light Shading Accent 1`.
|
| table_direction
| Member of :ref:`WdTableDirection` indicating cell-ordering direction.
|
| For example: `WD_TABLE_DIRECTION.LTR`. |None| indicates the value is inherited
| from the style hierarchy.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from docx.shared.StoryChild:
|
| part
| The package part containing this object.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from docx.shared.StoryChild:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
DATA
Iterator = typing.Iterator
A generic version of collections.abc.Iterator.
TYPE_CHECKING = False
TableParent = 'Table | _Columns | _Rows'
TypeAlias = typing.TypeAlias
Special form for marking type aliases.
Use TypeAlias to indicate that an assignment should
be recognized as a proper type alias definition by type
checkers.
For example::
Predicate: TypeAlias = Callable[..., bool]
It's invalid when used anywhere except as in the example above.
__annotations__ = {'TableParent': 'TypeAlias'}
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\docx\table.py
docx.text
Python Library Documentation: package docx.text in docx
NAME
docx.text
PACKAGE CONTENTS
font
hyperlink
pagebreak
paragraph
parfmt
run
tabstops
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\docx\text\__init__.py