---
title: "Document"
canonical_url: "https://www.nutrient.io/api/python/document/"
md_url: "https://www.nutrient.io/api/python/document.md"
last_updated: "2026-06-15T11:02:36.126Z"
description: "Represents a document that can be opened, edited, and exported in various formats."
---

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.

```python

from nutrient_sdk import Document

```

## Construction

```python

Document()

```

Creates a new `Document` instance with default settings.

## Class Methods

### open

```python

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

```

```python

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

```

Opens a document from a file path using default settings.

**Parameters:**

| Name                    | Type                                                                   | Description                                    |
| ----------------------- | ---------------------------------------------------------------------- | ---------------------------------------------- |
| `file_path`             | `str`                                                                  | The path to the document file to open.         |
| `settings` *(optional)* | [`DocumentSettings`](/api/python/settings/document/document-settings/) | The settings to use when opening the document. |

**Returns:** [`Document`](/api/python/document/) - A new Document instance representing the opened document.

---

## Methods

### export

```python

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

```

Exports the document to a file using the specified exporter.

**Parameters:**

| Name       | Type                                              | Description                                               |
| ---------- | ------------------------------------------------- | --------------------------------------------------------- |
| `filepath` | `str`                                             | The path where the exported file will be saved.           |
| `exporter` | [`IExporter`](/api/python/interfaces/i-exporter/) | The exporter that defines the output format and settings. |

---

### export_as_html

```python

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

```

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

**Parameters:**

| Name       | Type  | Description                                          |
| ---------- | ----- | ---------------------------------------------------- |
| `filepath` | `str` | The file path where the HTML document will be saved. |

---

### export_as_image

```python

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

```

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

**Parameters:**

| Name       | Type  | Description                                           |
| ---------- | ----- | ----------------------------------------------------- |
| `filepath` | `str` | The file path where the image document will be saved. |

---

### export_as_markdown

```python

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

```

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

**Parameters:**

| Name       | Type  | Description                                              |
| ---------- | ----- | -------------------------------------------------------- |
| `filepath` | `str` | The file path where the Markdown document will be saved. |

---

### export_as_pdf

```python

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

```

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

**Parameters:**

| Name       | Type  | Description                                         |
| ---------- | ----- | --------------------------------------------------- |
| `filepath` | `str` | The file path where the PDF document will be saved. |

---

### export_as_presentation

```python

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

```

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

**Parameters:**

| Name       | Type  | Description                                                  |
| ---------- | ----- | ------------------------------------------------------------ |
| `filepath` | `str` | The file path where the presentation document will be saved. |

---

### export_as_spreadsheet

```python

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

```

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

**Parameters:**

| Name       | Type  | Description                                                 |
| ---------- | ----- | ----------------------------------------------------------- |
| `filepath` | `str` | The file path where the spreadsheet document will be saved. |

---

### export_as_svg

```python

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

```

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

**Parameters:**

| Name       | Type  | Description                                         |
| ---------- | ----- | --------------------------------------------------- |
| `filepath` | `str` | The file path where the SVG document will be saved. |

---

### export_as_text

```python

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

```

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

**Parameters:**

| Name       | Type  | Description                                          |
| ---------- | ----- | ---------------------------------------------------- |
| `filepath` | `str` | The file path where the Text document will be saved. |

---

### export_as_word

```python

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

```

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

**Parameters:**

| Name       | Type  | Description                                          |
| ---------- | ----- | ---------------------------------------------------- |
| `filepath` | `str` | The file path where the Word document will be saved. |

---

## Properties

### page_count

```python

@property
def page_count(self) -> int

```

The total number of pages in the document.

**Type:** `int`

*Read-only property.*

---

### settings

```python

@property
def settings(self) -> DocumentSettings

```

The settings associated with this document instance.

**Type:** [`DocumentSettings`](/api/python/settings/document/document-settings/)

*Read-only property.*

---

### underlying_type

```python

@property
def underlying_type(self) -> DocumentType

```

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

**Type:** [`DocumentType`](/api/python/enums/document-type/)

*Read-only property.*

---

## Context manager

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

```python

with Document.open(...) as document:
    #... use document...

    pass  # closed automatically on exit

```

Or close explicitly:

```python

document = Document.open(...)
try:
    #... use document...

    pass
finally:
    document.close()

```

---

## Related pages

- [Open a PDF and convert it to a Word document](/api/python.md)
- [License](/api/python/license.md)
- [Vision](/api/python/vision.md)

