---
title: "Document"
canonical_url: "https://www.nutrient.io/api/csharp/document/"
md_url: "https://www.nutrient.io/api/csharp/document.md"
last_updated: "2026-10-08T08:55:57.709Z"
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.

```csharp

using Nutrient;

```

The SDK creates this class through factory methods or other SDK objects.

## Properties

### PageCount

```csharp

public int PageCount { get; }

```

The total number of pages in the document.

**Type:** `int`

### Settings

```csharp

public DocumentSettings Settings { get; }

```

The settings associated with this document instance.

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

### UnderlyingType

```csharp

public DocumentType UnderlyingType { get; }

```

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

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

## Methods

### ExportAsHtml

```csharp

public void ExportAsHtml(string filePath)

```

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

**Parameters**

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

```csharp

public void ExportAsHtml(Stream stream)

```

Exports the document as HTML format to the specified stream.

**Parameters**

| Name     | Type     | Description                                         |
| -------- | -------- | --------------------------------------------------- |
| `stream` | `Stream` | The stream where the HTML document will be written. |

### ExportAsImage

```csharp

public void ExportAsImage(string filePath)

```

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

**Parameters**

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

```csharp

public void ExportAsImage(Stream stream)

```

Exports the document as image format to the specified stream.

**Parameters**

| Name     | Type     | Description                                          |
| -------- | -------- | ---------------------------------------------------- |
| `stream` | `Stream` | The stream where the image document will be written. |

### ExportAsMarkdown

```csharp

public void ExportAsMarkdown(string filePath)

```

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

**Parameters**

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

```csharp

public void ExportAsMarkdown(Stream stream)

```

Exports the document as Markdown format to the specified stream.

**Parameters**

| Name     | Type     | Description                                             |
| -------- | -------- | ------------------------------------------------------- |
| `stream` | `Stream` | The stream where the Markdown document will be written. |

### ExportAsPdf

```csharp

public void ExportAsPdf(string filePath)

```

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

**Parameters**

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

```csharp

public void ExportAsPdf(Stream stream)

```

Exports the document as PDF format to the specified stream.

**Parameters**

| Name     | Type     | Description                                        |
| -------- | -------- | -------------------------------------------------- |
| `stream` | `Stream` | The stream where the PDF document will be written. |

### ExportAsPresentation

```csharp

public void ExportAsPresentation(string filePath)

```

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

**Parameters**

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

```csharp

public void ExportAsPresentation(Stream stream)

```

Exports the document as presentation format to the specified stream.

**Parameters**

| Name     | Type     | Description                                                 |
| -------- | -------- | ----------------------------------------------------------- |
| `stream` | `Stream` | The stream where the presentation document will be written. |

### ExportAsSpreadsheet

```csharp

public void ExportAsSpreadsheet(string filePath)

```

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

**Parameters**

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

```csharp

public void ExportAsSpreadsheet(Stream stream)

```

Exports the document as spreadsheet format to the specified stream.

**Parameters**

| Name     | Type     | Description                                                |
| -------- | -------- | ---------------------------------------------------------- |
| `stream` | `Stream` | The stream where the spreadsheet document will be written. |

### ExportAsSvg

```csharp

public void ExportAsSvg(string filePath)

```

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

**Parameters**

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

```csharp

public void ExportAsSvg(Stream stream)

```

Exports the document as SVG format to the specified stream.

**Parameters**

| Name     | Type     | Description                                        |
| -------- | -------- | -------------------------------------------------- |
| `stream` | `Stream` | The stream where the SVG document will be written. |

### ExportAsText

```csharp

public void ExportAsText(string filePath)

```

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

**Parameters**

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

```csharp

public void ExportAsText(Stream stream)

```

Exports the document as Text format to the specified stream.

**Parameters**

| Name     | Type     | Description                                         |
| -------- | -------- | --------------------------------------------------- |
| `stream` | `Stream` | The stream where the Text document will be written. |

### ExportAsWord

```csharp

public void ExportAsWord(string filePath)

```

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

**Parameters**

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

```csharp

public void ExportAsWord(Stream stream)

```

Exports the document as Word format to the specified stream.

**Parameters**

| Name     | Type     | Description                                         |
| -------- | -------- | --------------------------------------------------- |
| `stream` | `Stream` | The stream where the Word document will be written. |

### Open

```csharp

public static Document Open(string filePath)

```

Opens a document from a file path using default settings.

**Parameters**

| Name       | Type     | Description                            |
| ---------- | -------- | -------------------------------------- |
| `filePath` | `string` | The path to the document file to open. |

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

```csharp

public static Document Open(string filePath, DocumentSettings settings)

```

Opens a document from a file path using specified settings.

**Parameters**

| Name       | Type                                                                   | Description                                    |
| ---------- | ---------------------------------------------------------------------- | ---------------------------------------------- |
| `filePath` | `string`                                                               | The path to the document file to open.         |
| `settings` | [`DocumentSettings`](/api/csharp/settings/document/document-settings/) | The settings to use when opening the document. |

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

```csharp

public static Document Open(Stream stream)

```

Opens a document from a stream using default settings.

**Parameters**

| Name     | Type     | Description                              |
| -------- | -------- | ---------------------------------------- |
| `stream` | `Stream` | The stream containing the document data. |

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

```csharp

public static Document Open(Stream stream, DocumentSettings settings)

```

Opens a document from a stream using specified settings.

**Parameters**

| Name       | Type                                                                   | Description                                    |
| ---------- | ---------------------------------------------------------------------- | ---------------------------------------------- |
| `stream`   | `Stream`                                                               | The stream containing the document data.       |
| `settings` | [`DocumentSettings`](/api/csharp/settings/document/document-settings/) | The settings to use when opening the document. |

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

## Resource management

```csharp

public void Dispose()

```

`Document` implements `IDisposable` and owns native resources. Always call `Dispose()` or use a C# `using` declaration: it is not released automatically.

---

## Related pages

- [Csharp](/api/csharp.md)
- [Data Extraction](/api/csharp/data-extraction.md)
- [License](/api/csharp/license.md)
- [Query](/api/csharp/query.md)
- [Telemetry](/api/csharp/telemetry.md)
- [Vision](/api/csharp/vision.md)

