This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /api/csharp/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.

using Nutrient;

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

Properties

PageCount

public int PageCount { get; }

The total number of pages in the document.

Type: int

Settings

public DocumentSettings Settings { get; }

The settings associated with this document instance.

Type: DocumentSettings

UnderlyingType

public DocumentType UnderlyingType { get; }

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

Type: DocumentType

Methods

ExportAsHtml

public void ExportAsHtml(string filePath)

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

Parameters

NameTypeDescription
filePathstringThe file path where the HTML document will be saved.
public void ExportAsHtml(Stream stream)

Exports the document as HTML format to the specified stream.

Parameters

NameTypeDescription
streamStreamThe stream where the HTML document will be written.

ExportAsImage

public void ExportAsImage(string filePath)

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

Parameters

NameTypeDescription
filePathstringThe file path where the image document will be saved.
public void ExportAsImage(Stream stream)

Exports the document as image format to the specified stream.

Parameters

NameTypeDescription
streamStreamThe stream where the image document will be written.

ExportAsMarkdown

public void ExportAsMarkdown(string filePath)

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

Parameters

NameTypeDescription
filePathstringThe file path where the Markdown document will be saved.
public void ExportAsMarkdown(Stream stream)

Exports the document as Markdown format to the specified stream.

Parameters

NameTypeDescription
streamStreamThe stream where the Markdown document will be written.

ExportAsPdf

public void ExportAsPdf(string filePath)

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

Parameters

NameTypeDescription
filePathstringThe file path where the PDF document will be saved.
public void ExportAsPdf(Stream stream)

Exports the document as PDF format to the specified stream.

Parameters

NameTypeDescription
streamStreamThe stream where the PDF document will be written.

ExportAsPresentation

public void ExportAsPresentation(string filePath)

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

Parameters

NameTypeDescription
filePathstringThe file path where the presentation document will be saved.
public void ExportAsPresentation(Stream stream)

Exports the document as presentation format to the specified stream.

Parameters

NameTypeDescription
streamStreamThe stream where the presentation document will be written.

ExportAsSpreadsheet

public void ExportAsSpreadsheet(string filePath)

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

Parameters

NameTypeDescription
filePathstringThe file path where the spreadsheet document will be saved.
public void ExportAsSpreadsheet(Stream stream)

Exports the document as spreadsheet format to the specified stream.

Parameters

NameTypeDescription
streamStreamThe stream where the spreadsheet document will be written.

ExportAsSvg

public void ExportAsSvg(string filePath)

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

Parameters

NameTypeDescription
filePathstringThe file path where the SVG document will be saved.
public void ExportAsSvg(Stream stream)

Exports the document as SVG format to the specified stream.

Parameters

NameTypeDescription
streamStreamThe stream where the SVG document will be written.

ExportAsText

public void ExportAsText(string filePath)

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

Parameters

NameTypeDescription
filePathstringThe file path where the Text document will be saved.
public void ExportAsText(Stream stream)

Exports the document as Text format to the specified stream.

Parameters

NameTypeDescription
streamStreamThe stream where the Text document will be written.

ExportAsWord

public void ExportAsWord(string filePath)

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

Parameters

NameTypeDescription
filePathstringThe file path where the Word document will be saved.
public void ExportAsWord(Stream stream)

Exports the document as Word format to the specified stream.

Parameters

NameTypeDescription
streamStreamThe stream where the Word document will be written.

Open

public static Document Open(string filePath)

Opens a document from a file path using default settings.

Parameters

NameTypeDescription
filePathstringThe path to the document file to open.

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

public static Document Open(string filePath, DocumentSettings settings)

Opens a document from a file path using specified settings.

Parameters

NameTypeDescription
filePathstringThe 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.

public static Document Open(Stream stream)

Opens a document from a stream using default settings.

Parameters

NameTypeDescription
streamStreamThe stream containing the document data.

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

public static Document Open(Stream stream, DocumentSettings settings)

Opens a document from a stream using specified settings.

Parameters

NameTypeDescription
streamStreamThe stream containing the document data.
settingsDocumentSettingsThe settings to use when opening the document.

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

Resource management

public void Dispose()

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