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 import DocumentClass Methods
open
@classmethoddef open(cls, file_path: str) -> DocumentOpens a document from a file path using default settings.
Parameters:
| Name | Type | Description |
|---|---|---|
file_path | str | The path to the document file to open. |
Returns: Document - A new Document instance representing the opened document.
open
@classmethoddef open(cls, file_path: str, settings: DocumentSettings) -> DocumentOpens a document from a file path using specified settings.
Parameters:
| Name | Type | Description |
|---|---|---|
file_path | str | The path to the document file to open. |
settings | DocumentSettings | The 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) -> NoneExports 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 | The exporter that defines the output format and settings. |
export_as_html
def export_as_html(self, filepath: str) -> NoneExports 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
def export_as_image(self, filepath: str) -> NoneExports 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
def export_as_markdown(self, filepath: str) -> NoneExports 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
def export_as_pdf(self, filepath: str) -> NoneExports 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
def export_as_presentation(self, filepath: str) -> NoneExports 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
def export_as_spreadsheet(self, filepath: str) -> NoneExports 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
def export_as_svg(self, filepath: str) -> NoneExports 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_word
def export_as_word(self, filepath: str) -> NoneExports 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
settings
@propertydef settings(self) -> DocumentSettingsGets the settings associated with this document instance.
Type: DocumentSettings
Read-only property.
underlying_type
@propertydef underlying_type(self) -> DocumentTypeGets the underlying document type (PDF, Word, Excel, etc.) of the opened document.
Type: DocumentType
Read-only property.