Provides specialized editing capabilities for Word documents. Supports template-based document generation and manipulation of OpenXML Word documents.

from nutrient import WordEditor

Class Methods

edit

@classmethod
def edit(cls, document: Document) -> WordEditor

Creates a new WordEditor instance and begins editing the specified document.

Parameters:

NameTypeDescription
documentDocumentThe document to edit.

Returns: WordEditor - A new WordEditor instance for editing the document.


Methods

apply_template_model

def apply_template_model(self, json_template: str) -> None

Applies a template model to the Word document from a JSON string.

Parameters:

NameTypeDescription
json_templatestrThe JSON string containing the template model data.

close

def close(self) -> None

Closes the editor and releases all associated resources.


save

def save(self) -> None

Saves the current changes made in the editor.


save_as

def save_as(self, path: str) -> None

Saves the current changes to a file at the specified path.

Parameters:

NameTypeDescription
pathstrThe file path where the document will be saved.

save_with_model_as

def save_with_model_as(self, path: str) -> None

Saves the Word document with the applied template model to a file.

Parameters:

NameTypeDescription
pathstrThe file path where the processed document will be saved.