docx package

Subpackages

Submodules

docx.docx_redactor module

docx.xml_redactor module

class docx.xml_redactor.XMLRedactor(path: str)[source]

Bases: object

For correct work this class you should edit xml.etree.ElementTree replace 862 line on : “return qnames, _namespace_map” Else DOCX-file after editing will contain wrong namespace

add_new_abstract_and_num(list_style: bool = True, levels_count: int = 1, bullet_symbol: str = '•', custom_ilvl_marking: Dict[int, Tuple[int, int]] | None = None) int[source]

This function added new abstractNum and num list_style – True: decimal, False: bullet Return id of new Num-object

delete_comment_by_id(comment_id: int | str)[source]
Parameters:

comment_id – id of comment, that should be deleted

edit_comment_by_id(comment_id: int | str, comment_text: str, new_author: str | None = None)[source]
Parameters:
  • comment_id – id of comment, that should be edited

  • comment_text – new text of comment

  • new_author – new author of comment

edit_list_style_by_paraIds(paraIds: List[str] | str, new_num: str | int)[source]

Replace the numId to newNum of all specified paragraphs :param paraIds: One or many paraIds, which we replace numId :param new_num: New numId :return: None

get_all_para_attributes() List[Dict[str, str]][source]

Get all paragraphs in word/document.xml with their attributes :return: List of attributes with their values

save(path: str | None = None)[source]

Save changes to files :param path: path to new files

Module contents