This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /api/python/document.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Document

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_sdk import Document

Construction

Document()

Creates a new Document instance with default settings.

Class Methods

open

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

Opens a document from a file path using default settings.

Parameters:

NameTypeDescription
file_pathstrThe path to the document file to open.
settings (optional)DocumentSettingsThe 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_text

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

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

Parameters:

NameTypeDescription
filepathstrThe file path where the Text 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

page_count

@property
def page_count(self) -> int

The total number of pages in the document.

Type: int

Read-only property.


settings

@property
def settings(self) -> DocumentSettings

The settings associated with this document instance.

Type: DocumentSettings

Read-only property.


underlying_type

@property
def underlying_type(self) -> DocumentType

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

Type: DocumentType

Read-only property.


Context manager

Document supports the context manager protocol. Use with to ensure native resources are released automatically:

with Document.open(...) as document:
# ... use document ...
pass # closed automatically on exit

Or close explicitly:

document = Document.open(...)
try:
# ... use document ...
pass
finally:
document.close()