WordEmbeddedDocument
OfficeIMO.Word
Represents an embedded document within a WordDocument.
Inheritance
- WordElement
- WordEmbeddedDocument
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.
Returned or exposed by 5
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
- Parent WordDocument.
- fileNameOrContent string
- File path or HTML content to embed.
- alternativeFormatImportPartType OfficeIMO.Word.WordAlternativeFormatImportPartType?
- Explicit part type or null to infer from the file extension.
- htmlFragment bool
- 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
Returns
Task<string?>public void Remove() #Removes the embedded document from the parent WordDocument.
public async Task SaveAsync(string fileName, CancellationToken cancellationToken = default) #Saves the embedded document to the specified file asynchronously.
Parameters
- fileName string
- cancellationToken System.Threading.CancellationToken = default
Returns
Taskpublic async Task SaveAsync(Stream stream, CancellationToken cancellationToken = default) #Saves the embedded document to a caller-owned stream asynchronously.
Parameters
- stream System.IO.Stream
- cancellationToken System.Threading.CancellationToken = default
Returns
Taskpublic MemoryStream ToStream() #Returns the embedded document payload in a new stream positioned at the beginning.
Returns
MemoryStreamInherited Methods
Properties
public string ContentType { get; } #Gets the content type of the embedded document.