Represents a document that can be opened, edited, and exported in various formats. Provides a unified interface for working with different document types including PDF, Word, Excel, and more.

from nutrient import Document

Class Methods

open

@classmethod
def open(cls, file_path: str) -> Document

Opens a document from a file path using default settings.

Parameters:

NameTypeDescription
file_pathstrThe path to the document file to open.

Returns: Document - A new Document instance representing the opened document.


open

@classmethod
def open(cls, file_path: str, settings: DocumentSettings) -> Document

Opens a document from a file path using specified settings.

Parameters:

NameTypeDescription
file_pathstrThe path to the document file to open.
settingsDocumentSettingsThe settings to use when opening the document.

Returns: Document - A new Document instance representing the opened document.


Methods

export

def export(self, filepath: str, exporter: IExporter) -> None

Exports the document to a file using the specified exporter.

Parameters:

NameTypeDescription
filepathstrThe path where the exported file will be saved.
exporterIExporterThe exporter that defines the output format and settings.

export_as_html

def export_as_html(self, filepath: str) -> None

Exports the document as Html format to the specified file path.

Parameters:

NameTypeDescription
filepathstrThe file path where the Html document will be saved.

export_as_image

def export_as_image(self, filepath: str) -> None

Exports the document as Image format to the specified file path.

Parameters:

NameTypeDescription
filepathstrThe file path where the Image document will be saved.

export_as_markdown

def export_as_markdown(self, filepath: str) -> None

Exports the document as Markdown format to the specified file path.

Parameters:

NameTypeDescription
filepathstrThe file path where the Markdown document will be saved.

export_as_pdf

def export_as_pdf(self, filepath: str) -> None

Exports the document as Pdf format to the specified file path.

Parameters:

NameTypeDescription
filepathstrThe file path where the Pdf document will be saved.

export_as_presentation

def export_as_presentation(self, filepath: str) -> None

Exports the document as Presentation format to the specified file path.

Parameters:

NameTypeDescription
filepathstrThe file path where the Presentation document will be saved.

export_as_spreadsheet

def export_as_spreadsheet(self, filepath: str) -> None

Exports the document as Spreadsheet format to the specified file path.

Parameters:

NameTypeDescription
filepathstrThe file path where the Spreadsheet document will be saved.

export_as_svg

def export_as_svg(self, filepath: str) -> None

Exports the document as Svg format to the specified file path.

Parameters:

NameTypeDescription
filepathstrThe file path where the Svg document will be saved.

export_as_word

def export_as_word(self, filepath: str) -> None

Exports the document as Word format to the specified file path.

Parameters:

NameTypeDescription
filepathstrThe file path where the Word document will be saved.

Properties

settings

@property
def settings(self) -> DocumentSettings

Gets the settings associated with this document instance.

Type: DocumentSettings

Read-only property.


underlying_type

@property
def underlying_type(self) -> DocumentType

Gets the underlying document type (PDF, Word, Excel, etc.) of the opened document.

Type: DocumentType

Read-only property.