Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

WordEmbeddedDocument

OfficeIMO.Word

Namespace
OfficeIMO.Word
Assembly
OfficeIMO.Word
Source revision
0eef6a5756b9 with working tree changes

Represents an embedded document within a WordDocument.

Inheritance

Usage

Explore 6 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Accepted by parameters 1

Constructors

public WordEmbeddedDocument(WordDocument wordDocument, string fileNameOrContent, WordAlternativeFormatImportPartType? alternativeFormatImportPartType, bool htmlFragment) #

Initializes a new instance of the WordEmbeddedDocument class using the specified file or HTML fragment.

Parameters

wordDocument OfficeIMO.Word.WordDocument required
Parent WordDocument.
fileNameOrContent string required
File path or HTML content to embed.
alternativeFormatImportPartType OfficeIMO.Word.WordAlternativeFormatImportPartType? required
Explicit part type or null to infer from the file extension.
htmlFragment bool required
When true, fileNameOrContent is treated as HTML markup rather than a file path.

Methods

public string? GetHtml() #

Retrieves the HTML markup of the embedded document when available.

Returns

string? HTML content or null if the embedded document is not HTML.
public async Task<string?> GetHtmlAsync(CancellationToken cancellationToken = default) #

Asynchronously retrieves the HTML markup of the embedded document when available.

Parameters

cancellationToken System.Threading.CancellationToken = default optional

Returns

Task<string?>
public Stream OpenRead() #

Opens a readable stream for the embedded document payload.

Returns

Stream
public void Remove() #

Removes the embedded document from the parent WordDocument.

Save 2 overloads
public void Save(string fileName) #

Saves the embedded document to the specified file.

Parameters

fileName string required
Target file path.
public void Save(Stream stream) #

Saves the embedded document to a caller-owned stream.

Parameters

stream System.IO.Stream required
SaveAsync 2 overloads
public async Task SaveAsync(string fileName, CancellationToken cancellationToken = default) #

Saves the embedded document to the specified file asynchronously.

Parameters

fileName string required
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task
public async Task SaveAsync(Stream stream, CancellationToken cancellationToken = default) #

Saves the embedded document to a caller-owned stream asynchronously.

Parameters

stream System.IO.Stream required
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task
public byte[] ToBytes() #

Returns a copy of the embedded document payload.

Returns

byte[]
public MemoryStream ToStream() #

Returns the embedded document payload in a new stream positioned at the beginning.

Returns

MemoryStream

Properties

public string ContentType { get; } #

Gets the content type of the embedded document.