Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

WordDocument

OfficeIMO.Word

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

Provides functionality for creating, loading and manipulating Word documents.

Inheritance

  • object
  • WordDocument

Usage

Explore 71 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 61

Examples

using OfficeIMO.Word;

using var document = WordDocument.Create();
document.AddParagraph("Hello from OfficeIMO.");
document.Save("hello.docx");

Constructors

public WordDocument() #

Methods

AcceptRevisions 3 overloads
public void AcceptRevisions(string authorName) #

Given author name, accept all revisions by given Author.

Parameters

authorName string required
Author whose revisions should be accepted.
public void AcceptRevisions() #

Accept all revisions in the document.

public WordRevisionOperationReport AcceptRevisions(WordRevisionFilter filter) #

Accepts revisions that match the provided filter and returns a deterministic operation report.

Parameters

filter OfficeIMO.Word.WordRevisionFilter required
Filter describing revisions to accept.
public WordRevisionOperationReport AcceptRevisionsInParagraph(WordParagraph paragraph, WordRevisionFilter? filter = null) #

Accepts revisions inside the specified paragraph.

Parameters

paragraph OfficeIMO.Word.WordParagraph required
Paragraph that scopes the operation.
filter OfficeIMO.Word.WordRevisionFilter? = null optional
Optional additional filter.
public WordBookmark AddBookmark(string bookmarkName) #

Inserts a bookmark in a new paragraph.

Parameters

bookmarkName string required
Name of the bookmark.

Returns

WordBookmark The created WordBookmark.
public WordParagraph AddBreak(WordBreakType? breakType = null) #

Inserts a break into the document.

Parameters

breakType OfficeIMO.Word.WordBreakType? = null optional
Type of break to insert.

Returns

WordParagraph The created WordParagraph containing the break.
public WordParagraph AddCallout(OfficeCalloutKind kind, string title, string body, OfficeTheme? theme = null) #

Adds a shaded callout title and body, returning its title paragraph.

Parameters

kind OfficeIMO.OfficeCalloutKind required
title string required
body string required
theme OfficeIMO.OfficeTheme? = null optional
public IReadOnlyList<WordComment> AddCellComments(IEnumerable<WordCellComment> comments, CancellationToken cancellationToken = default) #

Adds root comments across body table cells, allocating identities and saving comment parts once per batch.

Parameters

comments System.Collections.Generic.IEnumerable<OfficeIMO.Word.WordCellComment> required
cancellationToken System.Threading.CancellationToken = default optional

Returns

IReadOnlyList<WordComment>
AddChart 3 overloads
public WordChart AddChart(string title = "", bool roundedCorners = false, OfficeLength? width = null, OfficeLength? height = null) #

Adds the chart to the document. The type of chart is determined by the type of data passed in. You can use multiple: .AddBar() to add a bar chart .AddLine() to add a line chart .AddPie() to add a pie chart .AddArea() to add an area chart .AddScatter() to add a scatter chart .AddRadar() to add a radar chart .AddBar3D() to add a 3-D bar chart. .AddPie3D() to add a 3-D pie chart. .AddLine3D() to add a 3-D line chart. You can't mix and match the types of charts, except bar and line which can coexist in a combo chart.

Parameters

title string = "" optional
The title.
roundedCorners bool = false optional
if set to true [rounded corners].
width OfficeIMO.OfficeLength? = null optional
The width.
height OfficeIMO.OfficeLength? = null optional
The height.

Returns

WordChart WordChart
public WordChart AddChart(OfficeChartType chartKind, OfficeChartData data) #

Adds an editable native chart with the format's default title, size and placement.

Parameters

chartKind OfficeIMO.OfficeChartType required
data OfficeIMO.Drawing.OfficeChartData required

Returns

WordChart
public WordChart AddChart(OfficeChartType chartKind, OfficeChartData data, OfficeChartOptions? options) #

Creates an editable native chart and embedded worksheet from the shared OfficeIMO chart contract.

Parameters

chartKind OfficeIMO.OfficeChartType required
Default chart family, with optional per-series kinds for supported combinations.
data OfficeIMO.Drawing.OfficeChartData required
Categories, series, and their supported appearance.
options OfficeIMO.OfficeChartOptions? required
Optional title, physical size and Word frame options. The default size is 600 by 600 pixels.

Returns

WordChart The created chart.
AddChart``1 2 overloads
public WordChart AddChart<T>(OfficeChartType type, IEnumerable<T?> data, string category, params string[] series) #

Adds an editable native chart using property names, including names supplied with nameof.

Type Parameters

T

Parameters

type OfficeIMO.OfficeChartType required
data System.Collections.Generic.IEnumerable<T?> required
category string required
series string[] required

Returns

WordChart
public WordChart AddChart<T>(OfficeChartType type, IEnumerable<T?> data, string category, OfficeChartOptions? options, params string[] series) #

Adds an editable native chart using property names and shared or format-specific options.

Type Parameters

T

Parameters

type OfficeIMO.OfficeChartType required
data System.Collections.Generic.IEnumerable<T?> required
category string required
options OfficeIMO.OfficeChartOptions? required
series string[] required

Returns

WordChart
AddChart``2 2 overloads
public WordChart AddChart<T, TCategory>(OfficeChartType type, IEnumerable<T?> data, Func<T?, TCategory?> category, params OfficeSeries[] series) #

Adds an editable native chart from typed category data and numeric series.

Type Parameters

T
TCategory

Parameters

type OfficeIMO.OfficeChartType required
data System.Collections.Generic.IEnumerable<T?> required
category System.Func<T?, TCategory?> required
series OfficeIMO.OfficeSeries[] required

Returns

WordChart
public WordChart AddChart<T, TCategory>(OfficeChartType type, IEnumerable<T?> data, Func<T?, TCategory?> category, OfficeChartOptions? options, params OfficeSeries[] series) #

Adds an editable native chart from typed data with a title, size and optional format-specific placement.

Type Parameters

T
TCategory

Parameters

type OfficeIMO.OfficeChartType required
data System.Collections.Generic.IEnumerable<T?> required
category System.Func<T?, TCategory?> required
options OfficeIMO.OfficeChartOptions? required
series OfficeIMO.OfficeSeries[] required

Returns

WordChart
public WordField AddCitation(string sourceTag) #

Inserts a citation field referencing the specified source tag.

Parameters

sourceTag string required
Tag of the bibliographic source.

Returns

WordField The created WordField.
public WordParagraph AddCodeBlock(string code, string? language = null) #

Adds a code paragraph using a named monospace paragraph style. The language is a descriptive hint.

Parameters

code string required
language string? = null optional
public WordChart AddComboChart(string title = "", bool roundedCorners = false, OfficeLength? width = null, OfficeLength? height = null) #

Creates a chart ready for combining bar and line series. Use WordChart.AddCategories to supply category labels and then call WordChart.AddBar or WordChart.AddLine to add data. The call to AddCategories must be performed before adding any series so both chart types share the same axes.

Parameters

title string = "" optional
roundedCorners bool = false optional
width OfficeIMO.OfficeLength? = null optional
height OfficeIMO.OfficeLength? = null optional

Returns

WordChart
public WordCoverPage AddCoverPage(WordCoverPageTemplate coverPageTemplate) #

Adds a built-in cover page to the document.

Parameters

coverPageTemplate OfficeIMO.Word.WordCoverPageTemplate required
Cover page template to use.

Returns

WordCoverPage The created WordCoverPage.
AddCustomBulletList 3 overloads
public WordList AddCustomBulletList(char symbol, string fontFamily, OfficeColor? color, OfficeLength? fontSize = null) #

Adds a custom bullet list with formatting options.

Parameters

symbol char required
Bullet symbol.
fontFamily string required
Font family for the symbol.
color OfficeIMO.OfficeColor? required
Color of the symbol.
fontSize OfficeIMO.OfficeLength? = null optional
Font size.

Returns

WordList The created WordList.
public WordList AddCustomBulletList(WordBulletSymbol symbol, string fontFamily, OfficeColor? color = null, OfficeLength? fontSize = null) #

Adds a custom bullet list with formatting options.

Parameters

symbol OfficeIMO.Word.WordBulletSymbol required
Bullet symbol.
fontFamily string required
Font family for the symbol.
color OfficeIMO.OfficeColor? = null optional
Bullet color.
fontSize OfficeIMO.OfficeLength? = null optional
Font size in points.

Returns

WordList The created WordList.
public WordList AddCustomBulletList(WordListLevelKind kind, string fontFamily, OfficeColor? color = null, OfficeLength? fontSize = null) #

Adds a custom bullet list using the specified formatting.

Parameters

kind OfficeIMO.Word.WordListLevelKind required
Bullet level kind.
fontFamily string required
Font family for the bullet.
color OfficeIMO.OfficeColor? = null optional
Bullet color.
fontSize OfficeIMO.OfficeLength? = null optional
Font size in points.

Returns

WordList The created WordList.

Examples

using WordDocument document = WordDocument.Create(filePath);

WordList list = document.AddCustomBulletList(
    WordListLevelKind.BulletSquareSymbol,
    "Courier New",
    OfficeIMO.OfficeColor.Red,
    fontSize: global::OfficeIMO.OfficeLength.Points(16));

list.AddItem("Custom bullet item");
document.Save();
public WordList AddCustomList() #

Creates a custom list with no predefined levels for manual configuration.

Returns

WordList The created WordList.

Examples

using WordDocument document = WordDocument.Create(filePath);

WordList list = document.AddCustomList();
list.AddListLevel(1, WordListLevelKind.BulletSquareSymbol, "Courier New", color: OfficeIMO.OfficeColor.Parse("#FF0000"), fontSize: global::OfficeIMO.OfficeLength.Points(14));
list.AddListLevel(5, WordListLevelKind.BulletBlackCircle, "Arial", color: OfficeIMO.OfficeColor.Parse("#00FF00"), fontSize: global::OfficeIMO.OfficeLength.Points(10));

list.AddItem("First level item");
list.AddItem("Fifth level item", 4);
document.Save();
public WordEmbeddedDocument AddEmbeddedDocument(string fileName, WordAlternativeFormatImportPartType? type = null) #

Embeds another document as an alternative format part.

Parameters

fileName string required
Path to the document.
type OfficeIMO.Word.WordAlternativeFormatImportPartType? = null optional
Optional format part type.
public WordEmbeddedDocument AddEmbeddedFragment(string htmlContent, WordAlternativeFormatImportPartType type) #

Embeds HTML content as an alternative format part.

Parameters

htmlContent string required
HTML content to embed.
type OfficeIMO.Word.WordAlternativeFormatImportPartType required
Format part type.
public WordEmbeddedDocument AddEmbeddedFragmentAfter(WordParagraph paragraph, string htmlContent, WordAlternativeFormatImportPartType type = Html) #

Inserts an HTML fragment after the specified paragraph.

Parameters

paragraph OfficeIMO.Word.WordParagraph required
Paragraph after which the fragment should be inserted.
htmlContent string required
HTML content to insert.
type OfficeIMO.Word.WordAlternativeFormatImportPartType = Html optional
Optional format type of the fragment.
AddEmbeddedObject 2 overloads
public WordEmbeddedObject AddEmbeddedObject(string filePath, string imageFilePath, OfficeLength? width = null, OfficeLength? height = null) #

Embeds an object with a preview image.

Parameters

filePath string required
Path to the object file.
imageFilePath string required
Preview image path.
width OfficeIMO.OfficeLength? = null optional
Optional physical width; defaults to 64.8 points.
height OfficeIMO.OfficeLength? = null optional
Optional physical height; defaults to 64.8 points.

Returns

WordEmbeddedObject The created embedded object.
public WordEmbeddedObject AddEmbeddedObject(string filePath, WordEmbeddedObjectOptions options) #

Embeds an object with custom options.

Parameters

filePath string required
Path to the object file.
options OfficeIMO.Word.WordEmbeddedObjectOptions required
Embedding options.

Returns

WordEmbeddedObject The created embedded object.
public WordEndnoteSettings AddEndnoteProperties(WordNumberFormat? numberingFormat = null, WordEndnotePosition? position = null, WordNoteNumberRestart? restartNumbering = null, int? startNumber = null) #

Adds or updates endnote numbering for the first section and placement for the whole document.

Parameters

numberingFormat OfficeIMO.Word.WordNumberFormat? = null optional
Numbering format to apply.
position OfficeIMO.Word.WordEndnotePosition? = null optional
Document-wide endnote location. A position-only update preserves section numbering.
restartNumbering OfficeIMO.Word.WordNoteNumberRestart? = null optional
Restart numbering option.
startNumber int? = null optional
Starting number.
AddEquation 2 overloads
public WordEquation AddEquation(OfficeMathExpression expression) #

Adds an editable Word equation authored with the reusable OfficeIMO math model.

Parameters

expression OfficeIMO.Drawing.OfficeMathExpression required
public WordEquation AddEquation(string omml) #

Inserts an equation specified in OMML format.

Parameters

omml string required
OMML markup for the equation.

Returns

WordEquation The created WordParagraph.
AddField 3 overloads
public WordField AddField(WordFieldType wordFieldType, WordFieldFormat? wordFieldFormat = null, string? customFormat = null, bool advanced = false, List<string>? parameters = null) #

Adds a field to the document in a new paragraph.

Parameters

wordFieldType OfficeIMO.Word.WordFieldType required
Type of field to insert.
wordFieldFormat OfficeIMO.Word.WordFieldFormat? = null optional
Optional field format.
customFormat string? = null optional
Custom format string for date or time fields.
advanced bool = false optional
Whether to use advanced formatting.
parameters System.Collections.Generic.List<string>? = null optional
Additional switch parameters.

Returns

WordField The created WordField.
public WordField AddField(WordFieldCode fieldCode, WordFieldFormat? wordFieldFormat = null, string? customFormat = null, bool advanced = false) #

Adds a field represented by a WordFieldCode to the document in a new paragraph.

Parameters

fieldCode OfficeIMO.Word.WordFieldCode required
Field code instance describing instructions and switches.
wordFieldFormat OfficeIMO.Word.WordFieldFormat? = null optional
Optional field format.
customFormat string? = null optional
Custom format string for date or time fields.
advanced bool = false optional
Whether to use advanced formatting.

Returns

WordField The created WordField.
public WordField AddField(WordFieldBuilder builder, bool advanced = false) #

Adds a field built using WordFieldBuilder.

Parameters

builder OfficeIMO.Word.WordFieldBuilder required
Field builder instance.
advanced bool = false optional
Whether to use advanced formatting.

Returns

WordField The created WordField.
public WordFootnoteSettings AddFootnoteProperties(WordNumberFormat? numberingFormat = null, WordFootnotePosition? position = null, WordNoteNumberRestart? restartNumbering = null, int? startNumber = null) #

Adds or updates footnote configuration for the first section.

Parameters

numberingFormat OfficeIMO.Word.WordNumberFormat? = null optional
Numbering format to apply.
position OfficeIMO.Word.WordFootnotePosition? = null optional
Location of footnotes.
restartNumbering OfficeIMO.Word.WordNoteNumberRestart? = null optional
Restart numbering option.
startNumber int? = null optional
Starting number.
public WordParagraph AddHeading(string text, int level = 1) #

Adds a heading paragraph using the document's built-in heading style.

Parameters

text string required
Heading text.
level int = 1 optional
Heading level from one through nine.

Returns

WordParagraph The created heading paragraph.
public WordParagraph AddHorizontalLine(WordBorderStyle? lineType = null, OfficeColor? color = null, uint size = 12, uint space = 1) #

Inserts a horizontal line into the document.

Parameters

lineType OfficeIMO.Word.WordBorderStyle? = null optional
Border style of the line.
color OfficeIMO.OfficeColor? = null optional
Line color.
size uint = 12 optional
Line width in eighths of a point.
space uint = 1 optional
Space above and below the line.

Returns

WordParagraph The paragraph containing the line.
AddHyperLink 2 overloads
AddImage 2 overloads
public WordImage AddImage(string path, OfficeLength? width = null, OfficeLength? height = null, WordImageOptions? options = null) #

Adds an image in a new paragraph and returns its editable occurrence.

Parameters

path string required
width OfficeIMO.OfficeLength? = null optional
height OfficeIMO.OfficeLength? = null optional
options OfficeIMO.Word.WordImageOptions? = null optional

Returns

WordImage
public WordImage AddImage(Stream stream, OfficeLength? width = null, OfficeLength? height = null, WordImageOptions? options = null) #

Adds an image stream in a new paragraph without disposing the caller's stream.

Parameters

stream System.IO.Stream required
width OfficeIMO.OfficeLength? = null optional
height OfficeIMO.OfficeLength? = null optional
options OfficeIMO.Word.WordImageOptions? = null optional

Returns

WordImage
public async Task<WordImage> AddImageAsync(Uri uri, OfficeLength? width = null, OfficeLength? height = null, WordImageOptions? options = null, OfficeRemoteImageLoadOptions? remoteImageOptions = null, CancellationToken cancellationToken = default) #

Downloads a bounded remote image and embeds it in a new paragraph.

Parameters

uri System.Uri required
width OfficeIMO.OfficeLength? = null optional
height OfficeIMO.OfficeLength? = null optional
options OfficeIMO.Word.WordImageOptions? = null optional
remoteImageOptions OfficeIMO.Drawing.OfficeRemoteImageLoadOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task<WordImage>
public WordList AddList(WordListStyle style) #

Creates a list using one of the built-in numbering styles. For manually configured lists prefer WordDocument.AddCustomList.

Parameters

style OfficeIMO.Word.WordListStyle required

Returns

WordList
public WordList AddListBulleted() #

Adds a bulleted list using the default bulleted style.

Returns

WordList The created WordList.
public WordList AddListNumbered() #

Adds a numbered list using the default numbering style.

Returns

WordList The created WordList.
AddMacro 3 overloads
public WordMacroProject AddMacro(string filePath) #

Adds a VBA project to the document.

Parameters

filePath string required
Path to a vbaProject.bin file.
public WordMacroProject AddMacro(byte[] data) #

Adds a VBA project to the document from bytes.

Parameters

data byte[] required
VBA project data.
public WordMacroProject AddMacro(Stream stream, long? maxBytes = null) #

Adds or replaces a VBA project from a readable stream.

Parameters

stream System.IO.Stream required
Stream containing vbaProject.bin.
maxBytes long? = null optional
Optional maximum number of bytes accepted from the stream.
public WordParagraph AddPageBreak() #

Inserts a page break into the document.

Returns

WordParagraph The created WordParagraph representing the page break.
public WordPageNumberSettings AddPageNumbering(int? startNumber = null, WordNumberFormat? format = null) #

Adds or updates page numbering for the first section.

Parameters

startNumber int? = null optional
Starting page number.
format OfficeIMO.Word.WordNumberFormat? = null optional
Number format.
AddParagraph 2 overloads
public WordParagraph AddParagraph(WordParagraph? wordParagraph = null) #

Appends a paragraph to the document body.

Parameters

wordParagraph OfficeIMO.Word.WordParagraph? = null optional
Optional paragraph to append. When null a new paragraph is created.

Returns

WordParagraph The added WordParagraph instance.
public WordParagraph AddParagraph(string text) #

Adds a new paragraph containing the specified text.

Parameters

text string required
Text for the paragraph.

Returns

WordParagraph The created WordParagraph.
AddPictureBulletList 2 overloads
public WordList AddPictureBulletList(Stream imageStream, string fileName) #

Creates a bullet list where the bullet symbol is provided as an image.

Parameters

imageStream System.IO.Stream required
Stream containing the image data.
fileName string required
File name used to determine the image type.

Returns

WordList The created WordList.
public WordList AddPictureBulletList(string imagePath) #

Creates a bullet list where the bullet symbol is loaded from an image file.

Parameters

imagePath string required
Path to the image file.

Returns

WordList The created WordList.
public WordRepeatingSection AddRepeatingSection(string? sectionTitle = null, string? alias = null, string? tag = null) #

Adds a new paragraph with a repeating section content control.

Parameters

sectionTitle string? = null optional
Optional title of the repeating section.
alias string? = null optional
Optional alias for the control.
tag string? = null optional
Optional tag for the control.
AddSection 2 overloads
public WordSection AddSection(WordSectionBreakType breakType) #

Adds a new section using the specified OfficeIMO break type.

Parameters

breakType OfficeIMO.Word.WordSectionBreakType required
Section break type.

Returns

WordSection The created WordSection.
public WordSection AddSection() #

Adds a new section using the document default break behavior.

Returns

WordSection The created WordSection.
public WordShape AddShape(WordShapeType shapeType, OfficeLength width, OfficeLength height, OfficeColor? fillColor = null, OfficeColor? strokeColor = null, OfficeLength? strokeWeight = null, double arcSize = 0.25) #

Adds a basic shape to the document in a new paragraph.

Parameters

shapeType OfficeIMO.Word.WordShapeType required
Type of shape to create.
width OfficeIMO.OfficeLength required
Width or line end X.
height OfficeIMO.OfficeLength required
Height or line end Y.
fillColor OfficeIMO.OfficeColor? = null optional
Fill color; white when omitted.
strokeColor OfficeIMO.OfficeColor? = null optional
Stroke color; black when omitted.
strokeWeight OfficeIMO.OfficeLength? = null optional
Stroke thickness; one point when omitted.
arcSize double = 0.25 optional
Corner roundness fraction for rounded rectangles.

Returns

WordShape The created WordShape.
AddShapeDrawing 2 overloads
public WordShape AddShapeDrawing(WordShapeType shapeType, OfficeLength width, OfficeLength height) #

Adds a DrawingML shape to the document in a new paragraph.

Parameters

shapeType OfficeIMO.Word.WordShapeType required
Type of shape to create.
width OfficeIMO.OfficeLength required
Width.
height OfficeIMO.OfficeLength required
Height.

Returns

WordShape
public WordShape AddShapeDrawing(WordShapeType shapeType, OfficeLength width, OfficeLength height, OfficeLength left, OfficeLength top) #

Adds a DrawingML shape anchored at an absolute position on the page in a new paragraph.

Parameters

shapeType OfficeIMO.Word.WordShapeType required
width OfficeIMO.OfficeLength required
height OfficeIMO.OfficeLength required
left OfficeIMO.OfficeLength required
top OfficeIMO.OfficeLength required

Returns

WordShape
public WordSmartArt AddSmartArt(WordSmartArtType type) #

Inserts a SmartArt diagram into the document.

Parameters

type OfficeIMO.Word.WordSmartArtType required
Layout type of the SmartArt.

Returns

WordSmartArt The created WordSmartArt instance.
public WordStructuredDocumentTag AddStructuredDocumentTag(string text, string? alias = null, string? tag = null) #

Adds a new paragraph with a content control (structured document tag).

Parameters

text string required
Initial text of the control.
alias string? = null optional
Optional alias for the control.
tag string? = null optional
Optional tag for the control.
AddTable 5 overloads
public WordTable AddTable(IEnumerable<object?> items, OfficeTableOptions? options = null) #

Adds a table from runtime objects by projecting their public properties or dictionary keys into columns.

Parameters

items System.Collections.Generic.IEnumerable<object?> required
Objects to insert into the table. Column names come from the first item.
options OfficeIMO.OfficeTableOptions? = null optional
Common column selection, ordering, header, formatting, alignment, name and caption options. Pass WordTableOptions to choose the table style and layout mode.

Returns

WordTable The created WordTable.
public WordTable AddTable(int rows, int columns, WordTableStyle tableStyle = TableGrid) #

Adds a table to the end of the document body.

Parameters

rows int required
Number of rows to create.
columns int required
Number of columns to create.
tableStyle OfficeIMO.Word.WordTableStyle = TableGrid optional
Optional table style to apply.

Returns

WordTable The inserted WordTable instance.
public WordTable AddTable(object?[,] values, OfficeTableOptions? options = null) #

Adds an editable table from an existing rectangular matrix.

Parameters

values object?[,] required
options OfficeIMO.OfficeTableOptions? = null optional

Returns

WordTable
public WordTable AddTable(IEnumerable<string[]> rows, OfficeTableOptions? options = null) #

Adds existing array rows as table cells. The first row is the header when headers are enabled.

Parameters

rows System.Collections.Generic.IEnumerable<string[]> required
options OfficeIMO.OfficeTableOptions? = null optional

Returns

WordTable
public WordTable AddTable(IEnumerable<IReadOnlyList<string>> rows, OfficeTableOptions? options = null) #

Adds existing rows of text. The first row is the header when headers are enabled.

Parameters

rows System.Collections.Generic.IEnumerable<System.Collections.Generic.IReadOnlyList<string>> required
options OfficeIMO.OfficeTableOptions? = null optional

Returns

WordTable
public WordTableOfContent AddTableOfContent(WordTableOfContentsStyle tableOfContentStyle = Template1, int minLevel = 1, int maxLevel = 3, string? title = null, bool insertAtTop = false) #

Adds a table of contents to the current document.

Parameters

tableOfContentStyle OfficeIMO.Word.WordTableOfContentsStyle = Template1 optional
Optional style to use when creating the table of contents.
minLevel int = 1 optional
Minimum heading level to include (1..9).
maxLevel int = 3 optional
Maximum heading level to include (1..9).
title string? = null optional
Optional title replacing the template title.
insertAtTop bool = false optional
Places the table of contents before existing body content.

Returns

WordTableOfContent The created WordTableOfContent instance.
public WordList AddTableOfContentList(WordListStyle style) #

Creates a list configured for a table of contents.

Parameters

style OfficeIMO.Word.WordListStyle required
Numbering style to apply.

Returns

WordList The created WordList.
public WordTable AddTable<T>(IEnumerable<T?> rows, OfficeTableOptions? options = null) #

Adds an editable table from a single pass over typed properties, fields, or string-keyed dictionaries.

Type Parameters

T

Parameters

rows System.Collections.Generic.IEnumerable<T?> required
options OfficeIMO.OfficeTableOptions? = null optional

Returns

WordTable
public WordTextBox AddTextBox(string text, WordImageTextWrapping wrapTextImage = Square) #

Inserts a text box into the document.

Parameters

text string required
Initial text for the text box.
wrapTextImage OfficeIMO.Word.WordImageTextWrapping = Square optional
Text wrapping option.

Returns

WordTextBox The created WordTextBox.
public WordTextBox AddTextBoxVml(string text) #

Inserts a VML text box into the document.

Parameters

text string required
public WordImageOptimizationReport AnalyzeImageOptimization(WordImageOptimizationOptions? options = null, CancellationToken cancellationToken = default) #

Evaluates exact encoded-media candidates without changing the document or fetching linked images. Candidate byte savings do not include ZIP packaging and document-save normalization.

Parameters

options OfficeIMO.Word.WordImageOptimizationOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional
AppendDocument 2 overloads
public void AppendDocument(WordDocument source) #

Appends the content of another WordDocument to this document, keeping destination styles and the source page setup.

Parameters

source OfficeIMO.Word.WordDocument required
The document to append.
public void AppendDocument(WordDocument source, WordDocumentMergeOptions? options) #

Appends the content of another WordDocument to this document.

Parameters

source OfficeIMO.Word.WordDocument required
The document to append.
options OfficeIMO.Word.WordDocumentMergeOptions? required
Controls style and section handling. When null, defaults are used.
public WordDocument ApplyTheme(OfficeTheme theme) #

Restyles the current document with the shared theme while retaining content, semantic emphasis, fields, relationships, table sizing and section geometry. Typography and cell padding can change pagination.

Parameters

theme OfficeIMO.OfficeTheme required
The visual theme to apply explicitly.

Returns

WordDocument The current editable document.
public LegacyDocWriteAssessment AssessLegacyDocWrite(WordSaveOptions? options = null) #

Runs the real native DOC encoder without committing an artifact and returns a structured capability result. This allocates the candidate DOC bytes so the assessment cannot drift from the writer used by WordDocument.Save.

Parameters

options OfficeIMO.Word.WordSaveOptions? = null optional
public int CleanupDocument(WordDocumentCleanupOptions options = All) #

This method will combine identical runs in a paragraph. This is useful when you have a paragraph with multiple runs of the same style, that Microsoft Word creates. This feature is *EXPERIMENTAL* and may not work in all cases. It may impact on how your document looks like, please do extensive testing before using this feature.

Parameters

options OfficeIMO.Word.WordDocumentCleanupOptions = All optional

Returns

int
public WordSection CloneSection(int index) #

Clones the section at the specified index and inserts the clone after it.

Parameters

index int required
Zero based index of the section to clone.

Returns

WordSection The cloned WordSection.
public void ConvertRevisionsToMarkup() #

Converts tracked revisions into visible markup by replacing revision elements with formatted runs. Inserted text is underlined and colored blue, while deleted text is displayed with red strikethrough.

Create 3 overloads
public static WordDocument Create(WordCreateOptions? options = null) #

Create a new WordDocument

Parameters

options OfficeIMO.Word.WordCreateOptions? = null optional
Creation options. SaveOnDispose is invalid without an associated destination.
public static WordDocument Create(string filePath, WordCreateOptions? options = null) #

Creates a Word document associated with a path that is written on explicit save.

Parameters

filePath string required
Destination associated with the document.
options OfficeIMO.Word.WordCreateOptions? = null optional
Creation and persistence options.
public static WordDocument Create(Stream stream, WordCreateOptions? options = null) #

Create a new WordDocument writing directly to the provided stream.

Parameters

stream System.IO.Stream required
Destination stream.
options OfficeIMO.Word.WordCreateOptions? = null optional
Creation and persistence options.

Returns

WordDocument Instance of WordDocument.

Exceptions

  • ArgumentNullException – Thrown when stream is null.
public WordListNumbering CreateNumberingDefinition() #

Creates a numbering definition that can be customized and reused.

public WordTable CreateTable(int rows, int columns, WordTableStyle tableStyle = TableGrid) #

Creates a table without inserting it into the document.

Parameters

rows int required
Number of rows to create.
columns int required
Number of columns to create.
tableStyle OfficeIMO.Word.WordTableStyle = TableGrid optional
Optional table style to apply.

Returns

WordTable The newly created WordTable.
public void Dispose() #

Releases resources associated with this WordDocument instance.

public async ValueTask DisposeAsync() #

Releases resources associated with the document asynchronously.

Returns

ValueTask
EmbedFont 2 overloads
public void EmbedFont(string fontPath) #

Embeds a font into the document.

Parameters

fontPath string required
Path to a TrueType/OpenType font file.

Exceptions

  • ArgumentException – The font's embedding permission forbids embedding it.
public WordStyle EmbedFont(string fontPath, string styleId, string? styleName = null) #

Embeds a font and adds a paragraph style to this document that uses it.

Parameters

fontPath string required
Path to a TrueType/OpenType font file.
styleId string required
Identifier of the paragraph style. An existing style with this identifier is updated to use the font.
styleName string? = null optional
Optional friendly name for a new style.

Returns

WordStyle The paragraph style that uses the embedded font.

Exceptions

  • ArgumentException – The font's embedding permission forbids embedding it, or the style cannot be used.
public byte[] ExportFlatOpc(WordSaveOptions? options = null) #

Exports a Word Open XML package as a standalone Flat OPC XML document.

Parameters

options OfficeIMO.Word.WordSaveOptions? = null optional

Returns

byte[]
public Dictionary<string, object?> ExtractContentControlValues(WordContentControlFormKey keyMode = TagThenAlias) #

Extracts values from supported content controls into a form map keyed by tag or alias.

Parameters

keyMode OfficeIMO.Word.WordContentControlFormKey = TagThenAlias optional
Controls which metadata field is used as the map key.

Returns

Dictionary<string, object?> Extracted form values.
public byte[] ExtractEmbeddedPayload(string id, long? maxBytes = null) #

Extracts an embedded payload by its package-local id.

Parameters

id string required
Id returned by WordDocument.GetEmbeddedPayloads.
maxBytes long? = null optional
Optional extraction limit.

Returns

byte[]
ExtractMacros 2 overloads
public byte[] ExtractMacros() #

Extracts the VBA project as a byte array.

Returns

byte[] Byte array with macro content or null when no macros are present.
public byte[] ExtractMacros(long maxBytes) #

Extracts a VBA project while enforcing a maximum byte count.

Parameters

maxBytes long required

Returns

byte[]
public int FillContentControlValues(IReadOnlyDictionary<string, object?> values, WordContentControlFormKey keyMode = TagThenAlias) #

Fills supported content controls from a form map keyed by tag or alias.

Parameters

values System.Collections.Generic.IReadOnlyDictionary<string, object?> required
Values to apply.
keyMode OfficeIMO.Word.WordContentControlFormKey = TagThenAlias optional
Controls which metadata field is used as the map key.

Returns

int The number of controls updated.

Exceptions

  • InvalidOperationException – A supplied value targets locked content or would remove a locked nested control.
Find 2 overloads
public WordSearchResult Find(string text, OfficeTextSearchOptions? options = null) #

Finds literal text in the body, body tables, all section headers and footers, and ordinary footnotes and endnotes.

Parameters

text string required
Text to find.
options OfficeIMO.OfficeTextSearchOptions? = null optional
Comparison settings. null matches ordinally, ignoring case, inside or across words.

Returns

WordSearchResult The paragraphs containing matches, grouped by document part, and the total match count.
public WordSearchResult Find(Regex pattern) #

Finds text matching a regular expression in the body, body tables, all section headers and footers, and ordinary footnotes and endnotes.

Parameters

pattern System.Text.RegularExpressions.Regex required
Regular expression applied to each paragraph's text. Its own options control case and boundaries.

Returns

WordSearchResult The paragraphs containing matches, grouped by document part, and the total match count.
public OfficeAccessibilityReport FixAccessibility(WordAccessibilityFixOptions options) #

Applies the selected safe fixes (title, language, table header rows) and returns a fresh inspection with default options.

Parameters

options OfficeIMO.Word.WordAccessibilityFixOptions required

Returns

OfficeAccessibilityReport
public WordCheckBox? GetCheckBoxByAlias(string alias) #

Retrieves a checkbox control by its alias.

Parameters

alias string required
Alias of the checkbox.

Returns

WordCheckBox? The matching WordCheckBox or null.
public WordCheckBox? GetCheckBoxByTag(string tag) #

Retrieves a checkbox control by its tag value.

Parameters

tag string required
Tag value of the checkbox.

Returns

WordCheckBox? The matching WordCheckBox or null.
public WordComboBox? GetComboBoxByAlias(string alias) #

Retrieves a combo box control by its alias.

Parameters

alias string required

Returns

WordComboBox?
public WordComboBox? GetComboBoxByTag(string tag) #

Retrieves a combo box control by its tag value.

Parameters

tag string required

Returns

WordComboBox?
public WordDatePicker? GetDatePickerByAlias(string alias) #

Retrieves a date picker control by its alias.

Parameters

alias string required
Alias of the date picker.

Returns

WordDatePicker? The matching WordDatePicker or null.
public WordDatePicker? GetDatePickerByTag(string tag) #

Retrieves a date picker control by its tag value.

Parameters

tag string required
Tag value of the date picker.

Returns

WordDatePicker? The matching WordDatePicker or null.
public string? GetDocumentVariable(string name) #

Gets the value of a document variable or null if the variable does not exist.

Parameters

name string required
Variable name.

Returns

string?
public IReadOnlyDictionary<string, string> GetDocumentVariables() #

Returns a read-only view of all document variables.

Returns

IReadOnlyDictionary<string, string>
public WordDropDownList? GetDropDownListByAlias(string alias) #

Retrieves a dropdown list control by its alias.

Parameters

alias string required
Alias of the dropdown list.

Returns

WordDropDownList? The matching WordDropDownList or null.
public WordDropDownList? GetDropDownListByTag(string tag) #

Retrieves a dropdown list control by its tag value.

Parameters

tag string required
Tag value of the dropdown list.

Returns

WordDropDownList? The matching WordDropDownList or null.
GetEmbeddedPayloads 2 overloads
public IReadOnlyList<OfficeEmbeddedPayloadInfo> GetEmbeddedPayloads(OfficeEmbeddedPayloadInspectionOptions options, CancellationToken cancellationToken = default) #

Inventories payloads within explicit count/member/aggregate/work ceilings without scanning unrequested bytes unless hashing is requested.

Parameters

options OfficeIMO.OfficeEmbeddedPayloadInspectionOptions required
cancellationToken System.Threading.CancellationToken = default optional

Returns

IReadOnlyList<OfficeEmbeddedPayloadInfo>
public IReadOnlyList<OfficeEmbeddedPayloadInfo> GetEmbeddedPayloads(bool includeSha256 = false) #

Gets embedded package, OLE, and ActiveX payload metadata.

Parameters

includeSha256 bool = false optional
Whether to calculate a digest for every payload.

Returns

IReadOnlyList<OfficeEmbeddedPayloadInfo>
GetFooterForSection 2 overloads
public WordFooter? GetFooterForSection(int sectionIndex, WordHeaderFooterType type) #

Returns the footer for a specific section index (use -1 to target the last section).

Parameters

sectionIndex int required
type OfficeIMO.Word.WordHeaderFooterType required

Returns

WordFooter?
public WordFooter? GetFooterForSection(int sectionIndex = -1) #

Returns the default footer for a specific section index.

Parameters

sectionIndex int = -1 optional
Index of the section or -1 for the last section.

Returns

WordFooter?
GetHeaderForSection 2 overloads
public WordHeader? GetHeaderForSection(int sectionIndex, WordHeaderFooterType type) #

Returns the header for a specific section index (use -1 to target the last section).

Parameters

sectionIndex int required
type OfficeIMO.Word.WordHeaderFooterType required

Returns

WordHeader?
public WordHeader? GetHeaderForSection(int sectionIndex = -1) #

Returns the default header for a specific section index.

Parameters

sectionIndex int = -1 optional
Index of the section or -1 for the last section.

Returns

WordHeader?
public IReadOnlyList<byte[]> GetImageBytes() #

Returns the bytes of all embedded images in the document. Images linked externally are skipped.

Returns

IReadOnlyList<byte[]>
public WordListNumbering? GetNumberingDefinition(int abstractNumberId) #

Retrieves a numbering definition by its identifier.

Parameters

abstractNumberId int required
Identifier of the numbering definition.

Returns

WordListNumbering? The WordListNumbering if found; otherwise, null.
public WordPictureControl? GetPictureControlByAlias(string alias) #

Retrieves a picture control by its alias.

Parameters

alias string required
public WordPictureControl? GetPictureControlByTag(string tag) #

Retrieves a picture control by its tag value.

Parameters

tag string required
public WordRepeatingSection? GetRepeatingSectionByAlias(string alias) #

Retrieves a repeating section control by its alias.

Parameters

alias string required
public WordRepeatingSection? GetRepeatingSectionByTag(string tag) #

Retrieves a repeating section control by its tag value.

Parameters

tag string required
public WordStructuredDocumentTag? GetStructuredDocumentTagByAlias(string alias) #

Retrieves a structured document tag by its alias.

Parameters

alias string required
Alias of the control.
public WordStructuredDocumentTag? GetStructuredDocumentTagByTag(string tag) #

Retrieves a structured document tag by its tag value.

Parameters

tag string required
Tag value of the control.
public WordParagraph InsertParagraphAt(int index, WordParagraph? paragraph = null) #

Inserts a paragraph at the specified index within the body.

Parameters

index int required
Zero-based position at which to insert the paragraph.
paragraph OfficeIMO.Word.WordParagraph? = null optional
Optional paragraph to insert. When null a new paragraph is created.

Returns

WordParagraph The inserted WordParagraph.
public WordTable InsertTableAfter(WordParagraph anchor, WordTable table) #

Inserts an existing table after the provided paragraph.

Parameters

anchor OfficeIMO.Word.WordParagraph required
Paragraph after which the table will be inserted.
table OfficeIMO.Word.WordTable required
Table instance to insert.

Returns

WordTable The inserted WordTable.
Inspect 2 overloads
public WordDocumentInfo Inspect() #

Creates an independent snapshot of document metadata, sections, stories, paragraphs, tables, notes, and images.

Returns

WordDocumentInfo A snapshot suitable for inspection or serialization without retaining live Open XML elements.

Exceptions

  • InvalidDataException – Generated list markers exceed the supported marker length or document character budget.
public WordDocumentInfo Inspect(bool includeImageBytes, CancellationToken cancellationToken = default) #

Creates the native semantic snapshot, optionally retaining image descriptors without copying their payload bytes.

Parameters

includeImageBytes bool required
When false, image payloads are not read or copied; image metadata remains available.
cancellationToken System.Threading.CancellationToken = default optional
Cancellation checked between source sections, paragraphs, table cells and notes.
public OfficeAccessibilityReport InspectAccessibility(WordAccessibilityOptions? options = null) #

Inspects the document body against an accessibility policy: alternative text, headings, tables, links, contrast, floating objects, spacing, title and language.

Parameters

options OfficeIMO.Word.WordAccessibilityOptions? = null optional

Returns

OfficeAccessibilityReport
public OfficeEmbeddedPayloadInspection InspectEmbeddedPayloads(OfficeEmbeddedPayloadInspectionOptions? options = null, CancellationToken cancellationToken = default) #

Inventories inert native payloads and creates a bounded cumulative read session. Keep this document open for new reads; returned streams are detached and caller-owned.

Parameters

options OfficeIMO.OfficeEmbeddedPayloadInspectionOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

OfficeEmbeddedPayloadInspection
public WordFeatureReport InspectFeatures() #

Inspects document features and reports which ones OfficeIMO can edit, partially edit, preserve, or does not support yet.

public IReadOnlyList<WordFieldInfo> InspectFields() #

Inspects simple and complex Word fields across the main document, headers, footers, footnotes and endnotes.

Returns

IReadOnlyList<WordFieldInfo> A deterministic read-only field inventory with raw instructions, parsed tokens, result text and location metadata.
public OfficeHiddenDataReport InspectHiddenData() #

Finds metadata, personal information and hidden data, the way Office's Document Inspector does, without changing the document.

Returns

OfficeHiddenDataReport
public OfficeContentSafetyReport InspectLoadedContentSafety(OfficeContentSafetyOptions? options = null, CancellationToken cancellationToken = default) #

Inspects the currently loaded document without reopening, saving, or executing its content. Source-load limits remain the caller's responsibility.

Parameters

options OfficeIMO.ContentSafety.OfficeContentSafetyOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

OfficeContentSafetyReport
InspectReview 2 overloads
public WordReviewInfo InspectReview() #

Inspects comments, comment thread metadata, and tracked revisions without mutating the document.

public WordReviewInfo InspectReview(CancellationToken cancellationToken) #

Inspects native review markup with cancellation between source elements, without accepting or rejecting revisions.

Parameters

cancellationToken System.Threading.CancellationToken required
public WordReviewReport InspectReviewReport(params WordRevisionOperationReport[] actions) #

Creates a structured review report for comments, tracked revisions, unsupported review metadata, and optional accept/reject actions.

Parameters

actions OfficeIMO.Word.WordRevisionOperationReport[] required
Optional accept/reject operation reports to include in the report.
public WordSignatureInfo InspectSignatures() #

Inspects package-level digital-signature metadata without copying the encoded package or validating digests and cryptographic trust. Use WordDocument.ValidateSignatures for transform-aware digest and trust validation.

InspectVbaProject 2 overloads
public OfficeVbaProjectInfo? InspectVbaProject(bool includeSha256 = false) #

Inspects the attached VBA project without executing macro code.

Parameters

includeSha256 bool = false optional
Whether to calculate the project SHA-256 digest.

Returns

OfficeVbaProjectInfo? Project metadata, or null when the document has no VBA project.
public OfficeVbaProjectInfo? InspectVbaProject(bool includeSha256, long maxBytes) #

Inspects the attached VBA project while enforcing a decoded byte limit.

Parameters

includeSha256 bool required
Whether to calculate the project SHA-256 digest.
maxBytes long required
Maximum decoded VBA project bytes accepted.

Returns

OfficeVbaProjectInfo? Project metadata, or null when the document has no VBA project.
public OfficeVbaProjectInfo? InspectVbaProjectMetadata() #

Inventories the VBA part and signature relationship without reading its bytes or decoding module names. Payload length remains unknown.

Returns

OfficeVbaProjectInfo?
Load 4 overloads
public static WordDocument Load(string filePath, WordLoadOptions? options = null) #

Load WordDocument from filePath

Parameters

filePath string required
options OfficeIMO.Word.WordLoadOptions? = null optional
Access, persistence, style, and low-level package options.

Exceptions

  • FileNotFoundException
public static WordDocument Load(Stream stream, WordLoadOptions? options = null) #

Load WordDocument from stream

Parameters

stream System.IO.Stream required
Readable source. Editable writable seekable package sources become the associated destination; Word XML sources remain detached.
options OfficeIMO.Word.WordLoadOptions? = null optional
Access, persistence, style, and low-level package options.
public static WordDocument Load(string filePath, WordLoadOptions? options, out OfficeConversionReport report) #

Loads a Word file and returns its source-projection findings.

Parameters

filePath string required
options OfficeIMO.Word.WordLoadOptions? required
report OfficeIMO.OfficeConversionReport required
public static WordDocument Load(Stream stream, WordLoadOptions? options, out OfficeConversionReport report) #

Loads a Word stream and returns its source-projection findings.

Parameters

stream System.IO.Stream required
options OfficeIMO.Word.WordLoadOptions? required
report OfficeIMO.OfficeConversionReport required
LoadAsync 2 overloads
public static async Task<WordDocument> LoadAsync(string filePath, WordLoadOptions? options = null, CancellationToken cancellationToken = default) #

Asynchronously loads a WordDocument from the given file.

Parameters

filePath string required
Path to the file.
options OfficeIMO.Word.WordLoadOptions? = null optional
Access, persistence, style, and low-level package options.
cancellationToken System.Threading.CancellationToken = default optional
Cancellation token.

Returns

Task<WordDocument> Loaded WordDocument instance.

Exceptions

  • FileNotFoundException – Thrown when the file does not exist.
public static async Task<WordDocument> LoadAsync(Stream stream, WordLoadOptions? options = null, CancellationToken cancellationToken = default) #

Asynchronously loads a Word document from a readable stream.

Parameters

stream System.IO.Stream required
Stream containing binary DOC, Word Open XML, or standalone Word XML content.
options OfficeIMO.Word.WordLoadOptions? = null optional
Access, persistence, style, and low-level package options.
cancellationToken System.Threading.CancellationToken = default optional
Cancellation token.

Returns

Task<WordDocument> The loaded document. The caller retains ownership of stream.
public WordIndexConcordanceReport MarkIndexEntries(IEnumerable<WordIndexConcordanceEntry> entries, bool matchCase = false, bool matchWholeWord = true) #

Marks matching paragraphs with hidden XE fields from in-memory concordance entries.

Parameters

entries System.Collections.Generic.IEnumerable<OfficeIMO.Word.WordIndexConcordanceEntry> required
Concordance entries mapping search text to index text.
matchCase bool = false optional
Whether matching should be case-sensitive.
matchWholeWord bool = true optional
Whether matches require non-letter/digit boundaries around the search text.

Returns

WordIndexConcordanceReport A report describing the marks inserted and entries skipped.
MarkIndexEntriesFromConcordance 2 overloads
public WordIndexConcordanceReport MarkIndexEntriesFromConcordance(WordDocument concordanceDocument, bool matchCase = false, bool matchWholeWord = true) #

Reads a Word-style two-column concordance document and marks matching paragraphs with hidden XE fields.

Parameters

concordanceDocument OfficeIMO.Word.WordDocument required
Concordance document whose first table column contains search text and second column contains index text.
matchCase bool = false optional
Whether matching should be case-sensitive.
matchWholeWord bool = true optional
Whether matches require non-letter/digit boundaries around the search text.

Returns

WordIndexConcordanceReport A report describing the marks inserted and entries skipped.
public WordIndexConcordanceReport MarkIndexEntriesFromConcordance(string concordancePath, bool matchCase = false, bool matchWholeWord = true) #

Loads a Word-style two-column concordance document and marks matching paragraphs with hidden XE fields.

Parameters

concordancePath string required
Path to a concordance .docx file.
matchCase bool = false optional
Whether matching should be case-sensitive.
matchWholeWord bool = true optional
Whether matches require non-letter/digit boundaries around the search text.

Returns

WordIndexConcordanceReport A report describing the marks inserted and entries skipped.
public void NormalizeTablesForOnline() #

Walks all tables in body and headers/footers and normalizes their grid/widths so online viewers render them consistently.

public Stream OpenEmbeddedPayload(string id, long maximumBytes, CancellationToken cancellationToken = default) #

Opens a complete bounded read-only detached payload stream. The caller owns its lifetime; no external target is accessed.

Parameters

id string required
maximumBytes long required
cancellationToken System.Threading.CancellationToken = default optional

Returns

Stream
public IReadOnlyList<Stream> OpenImageStreams() #

Returns streams with data of all embedded images in the document. Images linked externally are skipped.

Returns

IReadOnlyList<Stream>
public void OpenInApplication(string? filePath = null) #

Opens the associated document in the operating system's registered application.

Parameters

filePath string? = null optional
public WordImageOptimizationReport OptimizeImages(WordImageOptimizationOptions? options = null, CancellationToken cancellationToken = default) #

Optimizes unique embedded raster media while retaining every relationship and drawing's geometry. All candidates are staged before mutation. Cancellation or candidate failure leaves media unchanged. Save through the normal Word save API to persist changes; signed packages are blocked by default.

Parameters

options OfficeIMO.Word.WordImageOptimizationOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional
public OfficeVbaProject? ReadVbaProject(OfficeVbaReadOptions? options = null) #

Reads a detached, editable native VBA project; returns null when no project exists.

Parameters

options OfficeIMO.OfficeVbaReadOptions? = null optional

Returns

OfficeVbaProject?
public WordTableOfContent RegenerateTableOfContent() #

Removes the existing table of contents and creates a new one at the same location.

Returns

WordTableOfContent The newly created WordTableOfContent.
RejectRevisions 3 overloads
public void RejectRevisions(string authorName) #

Reject all revisions by given author.

Parameters

authorName string required
Author whose revisions should be rejected.
public void RejectRevisions() #

Reject all revisions in the document.

public WordRevisionOperationReport RejectRevisions(WordRevisionFilter filter) #

Rejects revisions that match the provided filter and returns a deterministic operation report.

Parameters

filter OfficeIMO.Word.WordRevisionFilter required
Filter describing revisions to reject.
public WordRevisionOperationReport RejectRevisionsInParagraph(WordParagraph paragraph, WordRevisionFilter? filter = null) #

Rejects revisions inside the specified paragraph.

Parameters

paragraph OfficeIMO.Word.WordParagraph required
Paragraph that scopes the operation.
filter OfficeIMO.Word.WordRevisionFilter? = null optional
Optional additional filter.
public void RemoveAllComments() #

Removes all comments from the document.

RemoveComment 2 overloads
public void RemoveComment(string commentId) #

Removes comment with the specified id.

Parameters

commentId string required
Id of the comment to remove.
public void RemoveComment(WordComment comment) #

Removes the specified comment from the document.

Parameters

comment OfficeIMO.Word.WordComment required
Comment instance to remove.
public void RemoveDocumentVariable(string name) #

Removes the document variable with the specified name if present.

Parameters

name string required
Variable name.
public void RemoveDocumentVariableAt(int index) #

Removes the document variable at the specified index.

Parameters

index int required
Zero-based index of the variable to remove.

Exceptions

  • ArgumentOutOfRangeException – Thrown when index is out of range.
public void RemoveEmbeddedDocument(WordEmbeddedDocument embeddedDocument) #

Removes an embedded document from the document.

Parameters

embeddedDocument OfficeIMO.Word.WordEmbeddedDocument required
Embedded document to remove.
public bool RemoveEmbeddedPayload(string id) #

Removes an embedded payload and known Word OLE/control markup that references it.

Parameters

id string required

Returns

bool
public OfficeHiddenDataReport RemoveHiddenData(OfficeHiddenDataOptions? options = null) #

Removes the selected categories of metadata and hidden data, then reports what was found and what happened to each item. Save the document to keep the result.

Parameters

options OfficeIMO.OfficeHiddenDataOptions? = null optional
Categories to remove; defaults to OfficeHiddenDataKind.Default, which keeps tracked changes and hidden content.

Returns

OfficeHiddenDataReport
public void RemoveMacro(string name) #

Removes a standard or class VBA module from the document.

Parameters

name string required
Module name to remove.

Exceptions

  • NotSupportedException – The named module belongs to the host document or a designer.
public void RemoveMacros() #

Removes the VBA project from the document.

RemoveProvenance 2 overloads
public static OfficeProvenanceRemovalResult RemoveProvenance(string inputPath, string outputPath, OfficeProvenanceRemovalOptions? options = null) #

Removes selected provenance and atomically writes an Open XML document.

Parameters

inputPath string required
outputPath string required
options OfficeIMO.Provenance.OfficeProvenanceRemovalOptions? = null optional

Returns

OfficeProvenanceRemovalResult
public static OfficeProvenanceRemovalResult RemoveProvenance(byte[] documentBytes, string fileName = "document.docx", OfficeProvenanceRemovalOptions? options = null) #

Removes selected provenance from encoded Open XML document bytes.

Parameters

documentBytes byte[] required
fileName string = "document.docx" optional
options OfficeIMO.Provenance.OfficeProvenanceRemovalOptions? = null optional

Returns

OfficeProvenanceRemovalResult
public void RemoveSection(int index) #

Removes the section at the specified index.

Parameters

index int required
Zero based index of the section to remove.
RemoveSelectedContent 2 overloads
public static OfficeContentCleanupResult RemoveSelectedContent(byte[] documentBytes, OfficeContentCleanupSelection selection, OfficeContentCleanupOptions? options = null) #

Removes exact selected concealed-content findings and reinspects the encoded document.

Parameters

documentBytes byte[] required
selection OfficeIMO.ContentSafety.OfficeContentCleanupSelection required
options OfficeIMO.ContentSafety.OfficeContentCleanupOptions? = null optional

Returns

OfficeContentCleanupResult
public static OfficeContentCleanupResult RemoveSelectedContent(string inputPath, string outputPath, OfficeContentCleanupSelection selection, OfficeContentCleanupOptions? options = null) #

Atomically writes an explicitly cleaned DOCX-family artifact.

Parameters

inputPath string required
outputPath string required
selection OfficeIMO.ContentSafety.OfficeContentCleanupSelection required
options OfficeIMO.ContentSafety.OfficeContentCleanupOptions? = null optional

Returns

OfficeContentCleanupResult
public void RemoveTableOfContent() #

Removes the current table of contents from the document if one exists.

public void RemoveWatermark() #

Removes all watermarks from the document including headers.

ReplaceAll 5 overloads
public int ReplaceAll(string text, string replacement, OfficeTextSearchOptions? options = null) #

Replaces literal text in the body, body tables, all section headers and footers, and ordinary footnotes and endnotes.

Parameters

text string required
Text to find.
replacement string required
Replacement text; null removes each match.
options OfficeIMO.OfficeTextSearchOptions? = null optional
Comparison settings. null matches ordinally, ignoring case, inside or across words.

Returns

int The number of replaced matches.
public static int ReplaceAll(List<WordParagraph> paragraphs, string text, string replacement, OfficeTextSearchOptions? options = null) #

Replaces literal text within the supplied paragraphs, such as the paragraphs of one table cell.

Parameters

paragraphs System.Collections.Generic.List<OfficeIMO.Word.WordParagraph> required
Paragraphs to search, in document order.
text string required
Text to find.
replacement string required
Replacement text; null removes each match.
options OfficeIMO.OfficeTextSearchOptions? = null optional
Comparison settings. null matches ordinally, ignoring case, inside or across words.

Returns

int The number of replaced matches.
public int ReplaceAll(Regex pattern, string replacement) #

Replaces regular-expression matches in the body, body tables, all section headers and footers, and ordinary footnotes and endnotes.

Parameters

pattern System.Text.RegularExpressions.Regex required
Regular expression applied to each paragraph's text.
replacement string required
Replacement pattern with the substitutions of Regex.Replace, such as $1 or ${name}.

Returns

int The number of replaced matches.
public int ReplaceAll(Regex pattern, MatchEvaluator evaluator) #

Replaces regular-expression matches with text computed for each match, in the same parts as WordDocument.ReplaceAll.

Parameters

pattern System.Text.RegularExpressions.Regex required
Regular expression applied to each paragraph's text.
evaluator System.Text.RegularExpressions.MatchEvaluator required
Returns the replacement text for a match.

Returns

int The number of replaced matches.
public int ReplaceAll(Regex pattern, Action<Match, WordParagraph> content) #

Replaces regular-expression matches with content added through a paragraph, such as formatted text, a hyperlink or an image, in the same parts as WordDocument.ReplaceAll.

Parameters

pattern System.Text.RegularExpressions.Regex required
Regular expression applied to each paragraph's text.
content System.Action<System.Text.RegularExpressions.Match, OfficeIMO.Word.WordParagraph> required
Adds the replacement for a match, for example (m, p) => p.AddText(m.Groups[1].Value).SetBold().

Returns

int The number of replaced matches.
ReplaceEmbeddedPayload 2 overloads
public void ReplaceEmbeddedPayload(string id, byte[] data) #

Replaces an embedded payload while preserving its owner relationship.

Parameters

id string required
data byte[] required
public void ReplaceEmbeddedPayload(string id, Stream stream, long? maxBytes = null) #

Replaces an embedded payload from a readable stream.

Parameters

id string required
stream System.IO.Stream required
maxBytes long? = null optional
public int ReplaceTextWithHtmlFragment(string textToFind, string htmlContent, WordAlternativeFormatImportPartType type = Html, StringComparison stringComparison = OrdinalIgnoreCase) #

Replaces each occurrence of text in consecutive body paragraphs with a block-level AltChunk at the match location, splitting a paragraph when necessary.

Parameters

textToFind string required
Text to search for.
htmlContent string required
HTML fragment to insert.
type OfficeIMO.Word.WordAlternativeFormatImportPartType = Html optional
Optional format type of the fragment.
stringComparison System.StringComparison = OrdinalIgnoreCase optional
String comparison option for the search.

Returns

int The number of replacements performed.

Exceptions

  • NotSupportedException – A match intersects content that cannot be split or removed as body text, such as a field, content control, revision, or explicit page or column break. The operation also rejects a match that would move a paragraph's page-break-before boundary.
Save 6 overloads
public void Save() #

Save WordDocument to where it was open from

public void Save(WordSaveOptions? options) #

Saves to the associated destination with optional save settings.

Parameters

options OfficeIMO.Word.WordSaveOptions? required
public void Save(string filePath) #

Save WordDocument to given filePath

Parameters

filePath string required
public void Save(string filePath, WordSaveOptions? options) #

Save WordDocument to the given file path with optional save policy settings.

Parameters

filePath string required
Destination path.
options OfficeIMO.Word.WordSaveOptions? required
Optional save policy settings.
public void Save(Stream outputStream) #

Save the WordDocument to Stream

Parameters

outputStream System.IO.Stream required

Exceptions

  • InvalidOperationException
public void Save(Stream outputStream, WordSaveOptions? options) #

Save the WordDocument to Stream with optional save behavior.

Parameters

outputStream System.IO.Stream required
Writable stream that receives the document content. This one-time save does not change the associated destination.
options OfficeIMO.Word.WordSaveOptions? required
Optional save behaviors, including stream physical format selection and signed-document policy.

Exceptions

  • InvalidOperationException
SaveAsync 6 overloads
public Task SaveAsync(CancellationToken cancellationToken = default) #

Asynchronously saves the document to where it was open from.

Parameters

cancellationToken System.Threading.CancellationToken = default optional
Cancellation token.

Returns

Task
public Task SaveAsync(WordSaveOptions? options, CancellationToken cancellationToken = default) #

Asynchronously saves to the associated destination with optional save settings.

Parameters

options OfficeIMO.Word.WordSaveOptions? required
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task
public Task SaveAsync(string filePath, CancellationToken cancellationToken = default) #

Asynchronously saves the document to the specified file.

Parameters

filePath string required
The path to save the document to.
cancellationToken System.Threading.CancellationToken = default optional
Cancellation token.

Returns

Task
public Task SaveAsync(string filePath, WordSaveOptions? options, CancellationToken cancellationToken = default) #

Asynchronously saves the document to the specified file with optional save policy settings.

Parameters

filePath string required
The path to save the document to.
options OfficeIMO.Word.WordSaveOptions? required
Optional save policy settings.
cancellationToken System.Threading.CancellationToken = default optional
Cancellation token.

Returns

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

Asynchronously saves the document to a stream as DOCX.

Parameters

outputStream System.IO.Stream required
Writable destination stream.
cancellationToken System.Threading.CancellationToken = default optional
Cancellation token.

Returns

Task
public Task SaveAsync(Stream outputStream, WordSaveOptions? options, CancellationToken cancellationToken = default) #

Asynchronously saves the document to a stream as DOCX.

Parameters

outputStream System.IO.Stream required
Writable destination stream.
options OfficeIMO.Word.WordSaveOptions? required
Optional save policy settings.
cancellationToken System.Threading.CancellationToken = default optional
Cancellation token.

Returns

Task
public void SaveCopy(string filePath, WordSaveOptions? options = null) #

Saves an independent copy without changing this document's associated destination.

Parameters

filePath string required
Destination path.
options OfficeIMO.Word.WordSaveOptions? = null optional
Optional save policy settings.
public async Task SaveCopyAsync(string filePath, WordSaveOptions? options = null, CancellationToken cancellationToken = default) #

Asynchronously saves an independent copy without changing this document's associated destination.

Parameters

filePath string required
options OfficeIMO.Word.WordSaveOptions? = null optional
cancellationToken System.Threading.CancellationToken = default optional

Returns

Task
public void SaveEmbeddedPayload(string id, string filePath, long? maxBytes = null) #

Saves an embedded payload by its package-local id.

Parameters

id string required
filePath string required
maxBytes long? = null optional
SaveMacros 2 overloads
public void SaveMacros(string filePath) #

Saves the VBA project to a file.

Parameters

filePath string required
Destination path.
public void SaveMacros(string filePath, long maxBytes) #

Saves a VBA project while enforcing a maximum byte count.

Parameters

filePath string required
maxBytes long required
public void SetDocumentVariable(string name, string value) #

Sets the value of a document variable. Creates it if it does not exist.

Parameters

name string required
Variable name.
value string required
Variable value.
public void SetVbaProject(OfficeVbaProject project, OfficeVbaWriteOptions? options = null) #

Applies a native source project while preserving Word's VBA data and requiring explicit signature removal.

Parameters

project OfficeIMO.OfficeVbaProject required
options OfficeIMO.OfficeVbaWriteOptions? = null optional
public static WordMacroProjectSigningResult SignMacroProject(string filePath, IOfficeSecurityProvider securityProvider, string certificateThumbprint, WordMacroProjectSigningOptions? options = null) #

Clears existing VBA signatures, creates and verifies Microsoft's legacy, agile, and V3 profiles, and atomically commits the signed package or throws with a structured result.

Parameters

filePath string required
Path to a saved DOCM or DOTM package.
securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
Cryptographic provider supplied by the optional OfficeIMO.Security package.
certificateThumbprint string required
SHA-1 thumbprint of a certificate with an accessible private key in the configured store.
options OfficeIMO.Word.WordMacroProjectSigningOptions? = null optional
Optional certificate-store, OfficeSips, timestamp, validation, and resource policy.
SignPackage 3 overloads
public static OfficePackageSigningResult SignPackage(string filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 signingCertificate, OfficePackageSigningOptions? options) #

Creates and validates an OPC signature through the shared cross-host engine.

Parameters

filePath string required
securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
signingCertificate System.Security.Cryptography.X509Certificates.X509Certificate2 required
options OfficeIMO.Security.OfficePackageSigningOptions? required

Returns

OfficePackageSigningResult
public static WordPackageSigningResult SignPackage(string filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 certificate, WordPackageSigningOptions? options = null) #

Signs a saved DOCX package using the cross-platform OPC XML-signature engine and throws when signing cannot be completed and cryptographically verified.

Parameters

filePath string required
Path to the DOCX package to sign.
securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
Cryptographic provider supplied by the optional OfficeIMO.Security package.
certificate System.Security.Cryptography.X509Certificates.X509Certificate2 required
Certificate with a private key used for signing.
options OfficeIMO.Word.WordPackageSigningOptions? = null optional
Optional package-signing settings.

Returns

WordPackageSigningResult A signing result with structural, cryptographic, digest, and certificate-policy validation readback.
public static WordPackageSigningResult SignPackage(string filePath, IOfficeSecurityProvider securityProvider, string certificateThumbprint, WordPackageCertificateStoreOptions? certificateOptions = null, WordPackageSigningOptions? signingOptions = null) #

Resolves a signing certificate by thumbprint from the certificate store, signs a saved DOCX package, and throws when signing cannot be completed and cryptographically verified.

Parameters

filePath string required
Path to the DOCX package to sign.
securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
Cryptographic provider supplied by the optional OfficeIMO.Security package.
certificateThumbprint string required
Certificate thumbprint to locate.
certificateOptions OfficeIMO.Word.WordPackageCertificateStoreOptions? = null optional
Optional certificate-store lookup settings.
signingOptions OfficeIMO.Word.WordPackageSigningOptions? = null optional
Optional package-signing settings.

Returns

WordPackageSigningResult A signing result with structural, cryptographic, digest, and certificate-policy validation readback.
public static OfficeVbaSigningResult SignVbaProject(string filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 signingCertificate, OfficeVbaSigningOptions? options = null, IEnumerable<X509Certificate2>? certificateChain = null) #

Creates and atomically validates legacy, agile, and V3 VBA signatures through the shared owner.

Parameters

filePath string required
securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
signingCertificate System.Security.Cryptography.X509Certificates.X509Certificate2 required
options OfficeIMO.Security.OfficeVbaSigningOptions? = null optional
certificateChain System.Collections.Generic.IEnumerable<System.Security.Cryptography.X509Certificates.X509Certificate2>? = null optional

Returns

OfficeVbaSigningResult
public IReadOnlyList<WordDocument> SplitByHeading(int level = 1) #

Splits this document into one new document per heading, starting a piece at every top-level paragraph whose heading level is level or higher (for example every Heading 1 when the level is 1).

Parameters

level int = 1 optional
The deepest heading level that starts a new piece, from 1 to 9.

Returns

IReadOnlyList<WordDocument> The pieces in document order. Each is detached and must be saved with an explicit destination.
public IReadOnlyList<WordDocument> SplitBySection() #

Splits this document into one new document per section.

Returns

IReadOnlyList<WordDocument> The pieces in document order. Each is detached and must be saved with an explicit destination.
public bool StyleExists(string styleId) #

Determines whether a paragraph style with the specified identifier exists in the document.

Parameters

styleId string required
The case-sensitive style identifier to look for.

Returns

bool true if the style exists; otherwise, false.
public byte[] ToBytes(WordSaveOptions? options = null) #

Encodes this document using the selected physical format and output encryption.

Parameters

options OfficeIMO.Word.WordSaveOptions? = null optional

Returns

byte[]
public bool TryGetCompatibilitySourcePayload(out OfficeCompatibilitySourcePayload? payload, out string? error) #

Tries to read an original source retained by a compatibility conversion.

Parameters

payload OfficeIMO.OfficeCompatibilitySourcePayload? required
error string? required

Returns

bool
public static WordMacroProjectSigningResult TrySignMacroProject(string filePath, IOfficeSecurityProvider securityProvider, string certificateThumbprint, WordMacroProjectSigningOptions? options = null) #

Attempts to clear existing VBA signatures, create Microsoft's legacy, agile, and V3 profiles, verify every profile as it is created, prove VBA-project preservation, and atomically replace the file.

Parameters

filePath string required
Path to a saved DOCM or DOTM package.
securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
Cryptographic provider supplied by the optional OfficeIMO.Security package.
certificateThumbprint string required
SHA-1 thumbprint of a certificate with an accessible private key in the configured store.
options OfficeIMO.Word.WordMacroProjectSigningOptions? = null optional
Optional certificate-store, OfficeSips, timestamp, validation, and resource policy.
TrySignPackage 3 overloads
public static OfficePackageSigningResult TrySignPackage(string filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 signingCertificate, OfficePackageSigningOptions? options) #

Attempts shared OPC signature creation without throwing for an ordinary signing failure.

Parameters

filePath string required
securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
signingCertificate System.Security.Cryptography.X509Certificates.X509Certificate2 required
options OfficeIMO.Security.OfficePackageSigningOptions? required

Returns

OfficePackageSigningResult
public static WordPackageSigningResult TrySignPackage(string filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 certificate, WordPackageSigningOptions? options = null) #

Attempts to sign a saved DOCX package and returns a report instead of throwing for unsupported platforms or signing failures.

Parameters

filePath string required
Path to the DOCX package to sign.
securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
Cryptographic provider supplied by the optional OfficeIMO.Security package.
certificate System.Security.Cryptography.X509Certificates.X509Certificate2 required
Certificate with a private key used for signing.
options OfficeIMO.Word.WordPackageSigningOptions? = null optional
Optional package-signing settings.

Returns

WordPackageSigningResult A signing result with details and validation readback when available.
public static WordPackageSigningResult TrySignPackage(string filePath, IOfficeSecurityProvider securityProvider, string certificateThumbprint, WordPackageCertificateStoreOptions? certificateOptions = null, WordPackageSigningOptions? signingOptions = null) #

Attempts to resolve a signing certificate by thumbprint from the certificate store and sign a saved DOCX package.

Parameters

filePath string required
Path to the DOCX package to sign.
securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
Cryptographic provider supplied by the optional OfficeIMO.Security package.
certificateThumbprint string required
Certificate thumbprint to locate.
certificateOptions OfficeIMO.Word.WordPackageCertificateStoreOptions? = null optional
Optional certificate-store lookup settings.
signingOptions OfficeIMO.Word.WordPackageSigningOptions? = null optional
Optional package-signing settings.

Returns

WordPackageSigningResult A signing result with details and validation readback when available.
public static OfficeVbaSigningResult TrySignVbaProject(string filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 signingCertificate, OfficeVbaSigningOptions? options = null, IEnumerable<X509Certificate2>? certificateChain = null) #

Attempts shared atomic VBA signing and returns structured failure evidence.

Parameters

filePath string required
securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
signingCertificate System.Security.Cryptography.X509Certificates.X509Certificate2 required
options OfficeIMO.Security.OfficeVbaSigningOptions? = null optional
certificateChain System.Collections.Generic.IEnumerable<System.Security.Cryptography.X509Certificates.X509Certificate2>? = null optional

Returns

OfficeVbaSigningResult
UpdateFields 2 overloads
public void UpdateFields() #

Updates page and total page number fields. When a table of contents is present the document is flagged to refresh fields on open so Word can update the TOC.

public void UpdateFields(WordFieldUpdateOptions options) #

Updates page and total page number fields, using the supplied options for supported deterministic field refresh.

Parameters

options OfficeIMO.Word.WordFieldUpdateOptions required
Options controlling deterministic field refresh behavior.
UpdateFieldsAndGetReport 2 overloads
public WordFieldUpdateReport UpdateFieldsAndGetReport() #

Updates deterministic field results supported by OfficeIMO and returns structured per-field diagnostics.

Returns

WordFieldUpdateReport A report describing updated, skipped, unsupported and malformed fields.
public WordFieldUpdateReport UpdateFieldsAndGetReport(WordFieldUpdateOptions options) #

Updates deterministic field results supported by OfficeIMO and returns structured per-field diagnostics.

Parameters

options OfficeIMO.Word.WordFieldUpdateOptions required
Options controlling deterministic field refresh behavior.

Returns

WordFieldUpdateReport A report describing updated, skipped, unsupported and malformed fields.
public WordContentControlFormValidationResult ValidateContentControlValues(IReadOnlyDictionary<string, object?> values, WordContentControlFormKey keyMode = TagThenAlias, bool requireAllControls = true, bool allowUnusedValues = false) #

Validates a content-control form map before values are applied to the document.

Parameters

values System.Collections.Generic.IReadOnlyDictionary<string, object?> required
Values to validate.
keyMode OfficeIMO.Word.WordContentControlFormKey = TagThenAlias optional
Controls which metadata field is used as the map key.
requireAllControls bool = true optional
When true, report mapped controls that have no supplied value.
allowUnusedValues bool = false optional
When false, report supplied values that do not match a mapped control.

Returns

WordContentControlFormValidationResult Validation result containing expected keys, supplied keys, and issues.
public List<OfficeOpenXmlValidationError> ValidateDocument(OfficeOpenXmlFileFormatVersion fileFormatVersion = Microsoft365) #

Validates the document using the specified file format version.

Parameters

fileFormatVersion OfficeIMO.OfficeOpenXmlFileFormatVersion = Microsoft365 optional
File format version to validate against.

Returns

List<OfficeOpenXmlValidationError> List of validation errors.
public static WordMacroProjectSignatureValidationResult ValidateMacroProjectSignature(string filePath, IOfficeSecurityProvider securityProvider, WordMacroProjectSignatureValidationOptions? options = null) #

Validates the highest-precedence VBA signature against the macro project through Microsoft's registered Office SIP, then applies caller CMS, certificate-chain, revocation, and timestamp policy.

Parameters

filePath string required
Path to a saved DOCM or DOTM package.
securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
Cryptographic provider supplied by the optional OfficeIMO.Security package.
options OfficeIMO.Word.WordMacroProjectSignatureValidationOptions? = null optional
Optional native-tool and validation policy.
ValidateSignatures 2 overloads
public static OfficePackageSignatureValidationReport ValidateSignatures(string filePath, IOfficeSecurityProvider securityProvider, OfficePackageSignatureValidationOptions? options = null) #

Validates a saved DOCX/DOCM package through the shared optional-provider engine.

Parameters

filePath string required
securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
options OfficeIMO.Security.OfficePackageSignatureValidationOptions? = null optional

Returns

OfficePackageSignatureValidationReport
public WordSignatureValidationReport ValidateSignatures(IOfficeSecurityProvider securityProvider, WordSignatureValidationOptions? options = null) #

Validates package structure, transform-aware OPC digests, XML signature math, signer trust, revocation, and timestamps through an explicitly supplied security provider.

Parameters

securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
Cryptographic provider supplied by the caller, typically OfficeSecurityProvider.Default.
options OfficeIMO.Word.WordSignatureValidationOptions? = null optional
Trust, revocation, timestamp, and resource policy.
public static OfficeVbaSignatureValidationResult ValidateVbaSignatures(string filePath, IOfficeSecurityProvider securityProvider, OfficeVbaSignatureInspectionOptions? options = null) #

Validates VBA signatures through the package-neutral core shared with Excel and PowerPoint.

Parameters

filePath string required
securityProvider OfficeIMO.Security.IOfficeSecurityProvider required
options OfficeIMO.Security.OfficeVbaSignatureInspectionOptions? = null optional

Returns

OfficeVbaSignatureValidationResult

Properties

public WordTableOfContent? TableOfContent { get; } #

Gets the table of contents defined in the document.

public WordCoverPage? CoverPage { get; } #

Gets the cover page if one is defined in the document.

public List<WordElement> Elements { get; } #

List of all elements in the document from all the sections

public List<WordElement> ElementsByType { get; } #

List of all elements in the document from all the sections by their subtype

public List<WordBreak> PageBreaks { get; } #

List of all PageBreaks in the document from all the sections

public List<WordBreak> Breaks { get; } #

Collection of all break elements (page, column, or text wrapping) found across the document.

public List<WordEndNote> EndNotes { get; } #

Collection of all endnotes referenced throughout the document.

public List<WordFootNote> FootNotes { get; } #

Collection of all footnotes referenced throughout the document.

public List<WordList> Lists { get; } #

Gets the lists in the document

Value

The lists.

public List<WordBookmark> Bookmarks { get; } #

Provides a list of Bookmarks in the document from all the sections

public List<WordTable> Tables { get; } #

Provides a list of all tables within the document from all the sections, excluding nested tables

public List<WordWatermark> Watermarks { get; } #

Provides a list of all watermarks within the document from all the sections, including watermarks defined in headers.

public List<WordEmbeddedDocument> EmbeddedDocuments { get; } #

Provides a list of all embedded documents within the document.

public List<WordTable> TablesIncludingNestedTables { get; } #

Provides a list of all tables within the document from all the sections, including nested tables

public List<WordParagraph> ParagraphsImages { get; } #

Provides a list of paragraphs that contain Image

public List<WordImage> Images { get; } #

Exposes Images in their Image form for easy access (saving, modifying)

public List<WordEmbeddedObject> EmbeddedObjects { get; } #

Provides a list of all embedded objects within the document.

public List<WordField> Fields { get; } #

Provides a list of all fields within the document.

public List<WordChart> Charts { get; } #

Provides a list of all charts within the document.

public List<WordTextBox> TextBoxes { get; } #

Collection of all text boxes in the document.

public List<WordShape> Shapes { get; } #

Collection of all shapes in the document.

public List<WordSmartArt> SmartArts { get; } #

Collection of all SmartArt diagrams in the document.

public List<WordTabChar> TabChars { get; } #

Collection of tab character elements in the document.

public List<WordStructuredDocumentTag> StructuredDocumentTags { get; } #

Collection of structured document tags in the document.

public List<WordCheckBox> CheckBoxes { get; } #

Collection of all check boxes in the document.

public List<WordDatePicker> DatePickers { get; } #

Collection of all date picker controls in the document.

public List<WordDropDownList> DropDownLists { get; } #

Collection of all dropdown list controls in the document.

public List<WordComboBox> ComboBoxes { get; } #

Collection of all combo box controls in the document.

public List<WordPictureControl> PictureControls { get; } #

Collection of all picture controls in the document.

public List<WordRepeatingSection> RepeatingSections { get; } #

Collection of all repeating section controls in the document.

public List<WordEquation> Equations { get; } #

Collection of all equations in the document.

public WordPageSetup PageSetup { get; } #

Gets the page size, margins, orientation and running headers and footers of the first section.

public OfficePackageSecurityReport? SourcePackageSecurityReport { get; private set; } #

Structural observations captured from the exact loader source bytes when requested; subsequent edits do not change this source report.

public string? SourcePackageSecurityScope { get; private set; } #

Identifies whether captured observations describe the original source, its decrypted package, or a reconstructed package.

public WordFileFormat SourceFormat { get; private set; } #

Gets the detected physical format of the document source.

public OfficeFormatDescriptor SourceFormatDescriptor { get; } #

Gets the concrete source format, including modern template and macro variants.

public string? SourcePath { get; } #

Gets the original binary or standalone XML source path, or the current Open XML file association.

public IReadOnlyList<LegacyDocImportDiagnostic> LegacyDocImportDiagnostics { get; } #

Gets diagnostics produced while importing the legacy `.doc` document.

public IReadOnlyList<LegacyDocUnsupportedFeature> LegacyDocUnsupportedFeatures { get; } #

Gets unsupported or preserve-only features discovered while importing the legacy `.doc` document.

public IReadOnlyList<LegacyDocPreservedFeature> LegacyDocPreservedFeatures { get; } #

Gets preserve-only non-compound feature metadata discovered while importing the legacy `.doc` document.

public IReadOnlyList<LegacyDocCompoundFeature> LegacyDocCompoundFeatures { get; } #

Gets preserve-only compound storage discovered while importing the legacy `.doc` document.

public bool IsDisposed { get; } #

Whether this document has released its package and owned resources.

public bool HasMacros { get; } #

Provides basic support for VBA macro projects.

public IReadOnlyList<WordMacro> Macros { get; } #

Gets all VBA modules in the document, including host document and designer modules.

public List<WordComment> Comments { get; } #

Collection of all comments inserted into the document.

public bool HasDocumentVariables { get; } #

Determines whether the document contains any document variables.

public bool TrackChanges { get; set; } #

Enable or disable tracking of all revisions, moves and formatting changes.

public List<WordSection> Sections { get; } #

Collection of sections contained in the document.

public string? FilePath { get; internal set; } #

Path to the file backing this document.

public WordSettings Settings { get; internal set; } #

Provides access to document settings. A missing settings part is created on first use.

public WordApplicationProperties ApplicationProperties { get; internal set; } #

Manages application related properties.

public WordBuiltinDocumentProperties Properties { get; internal set; } #

Provides access to built-in document properties.

public WordCoverPageProperties CoverPageProperties { get; } #

Provides access to the cover page properties custom XML part used by built-in templates.

public Dictionary<string, WordCustomProperty> CustomProperties { get; } #

Collection of custom document properties.

public Dictionary<string, string> DocumentVariables { get; } #

Collection of document variables accessible via WordFieldType.DocVariable fields.

public Dictionary<string, WordBibliographySource> BibliographySources { get; } #

Collection of bibliographic sources used in the document.

public WordDocumentStatistics Statistics { get; internal set; } #

Provides basic statistics for the document.

public DocumentPersistenceMode PersistenceMode { get; } #

Gets the persistence policy selected when the document was created or loaded.

public bool AutoUpdateToc { get; set; } #

When true the table of contents is flagged to update before saving.

public WordprocessingDocument OpenXmlDocument { get; } #

Gets the underlying Open XML package for advanced integration scenarios.

public FileAccess FileOpenAccess { get; } #

FileOpenAccess of the document

public DocumentAccessMode AccessMode { get; } #

Gets whether the document was loaded for reading or editing.

public List<WordParagraph> Paragraphs { get; } #

Returns all paragraphs from every section of the document.

public List<WordParagraph> ParagraphsPageBreaks { get; } #

Returns paragraphs that contain page breaks.

public List<WordParagraph> ParagraphsBreaks { get; } #

Returns paragraphs that contain any break elements.

public List<WordParagraph> ParagraphsTabs { get; } #

Returns paragraphs that contain tab characters.

public List<WordParagraph> ParagraphsTabStops { get; } #

Returns paragraphs that define tab stops.

public List<WordParagraph> ParagraphsFields { get; } #

Returns paragraphs that include fields.

public List<WordParagraph> ParagraphsBookmarks { get; } #

Returns paragraphs that contain bookmarks.

public List<WordParagraph> ParagraphsEquations { get; } #

Returns paragraphs containing equations.

public List<WordParagraph> ParagraphsStructuredDocumentTags { get; } #

Returns paragraphs that host structured document tags.

public List<WordParagraph> ParagraphsCheckBoxes { get; } #

Returns paragraphs that contain check boxes.

public List<WordParagraph> ParagraphsDatePickers { get; } #

Returns paragraphs that contain date picker controls.

public List<WordParagraph> ParagraphsDropDownLists { get; } #

Returns paragraphs that contain dropdown list controls.

public List<WordParagraph> ParagraphsComboBoxes { get; } #

Returns paragraphs that contain combo box controls.

public List<WordParagraph> ParagraphsPictureControls { get; } #

Returns paragraphs that contain picture controls.

public List<WordParagraph> ParagraphsRepeatingSections { get; } #

Returns paragraphs that contain repeating section controls.

public List<WordParagraph> ParagraphsCharts { get; } #

Returns paragraphs with embedded charts.

public List<WordParagraph> ParagraphsEndNotes { get; } #

Returns paragraphs referencing endnotes.

public List<WordParagraph> ParagraphsTextBoxes { get; } #

Returns paragraphs that contain text boxes.

public List<WordParagraph> ParagraphsShapes { get; } #

Provides a list of paragraphs that contain shapes.

public List<WordParagraph> ParagraphsSmartArts { get; } #

Returns paragraphs that contain SmartArt diagrams.

public List<WordParagraph> ParagraphsEmbeddedObjects { get; } #

Returns paragraphs containing embedded objects.

public List<WordParagraph> ParagraphsFootNotes { get; } #

Returns paragraphs referencing footnotes.

public IReadOnlyList<WordStructuredDocumentTag> TextContentControls { get; } #

Gets generic text content controls without the SDT wrappers belonging to native check boxes, dates, choices, pictures or repeating sections.

public WordBorders Borders { get; set; } #

Gets or sets the page borders for the first section.

public bool RtlGutter { get; set; } #

Gets or sets a value indicating whether the gutter should appear on the right for right-to-left pages in the first section.

public WordStyleCollection Styles { get; } #

Gets the styles this document defines, to list, inspect, create, change, remove and import them.

public WordTheme Theme { get; } #

Gets the document theme: its colour scheme and its heading and body fonts.

public WordBackground Background { get; set; } #

Provides access to the document background settings.

public bool DocumentIsValid { get; } #

Indicates whether the document passes Open XML validation.

public List<OfficeOpenXmlValidationError> DocumentValidationErrors { get; } #

Gets the list of validation errors for the document.

public WordCompatibilitySettings CompatibilitySettings { get; set; } #

Gets or sets compatibility settings for the document.

public WordPageNumberSettings PageNumberSettings { get; } #

Gets the editable configuration of the first section's page-numbering configuration.

public WordFootnoteSettings FootnoteSettings { get; } #

Gets the editable configuration of the first section's footnote configuration.

public WordEndnoteSettings EndnoteSettings { get; } #

Gets the editable configuration of the first section's endnote configuration.

Extension Methods

public static WordParagraph AddParagraphFromXml(WordDocument document, string xml) #

Creates a WordParagraph from the provided XML string and appends it to the document.

Parameters

document OfficeIMO.Word.WordDocument required
Target document.
xml string required
XML string representing a paragraph.

Returns

WordParagraph The inserted WordParagraph.