API Reference
WordDocument
Defines default document settings parts.
Inheritance
- Object
- WordDocument
Usage
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by
- Method WordFluentDocument.End
- Property LegacyDocLoadResult.Document
- Method WordDocument.Create
- Method WordDocument.Create
- Method WordDocument.Create
- Method WordDocument.Load
- Method WordDocument.Load
- Method WordDocument.LoadAsync
- Method WordDocument.LoadAsync
- Method WordDocument.LoadEncrypted
- Method WordDocument.LoadEncrypted
- Method WordDocument.LoadLegacyDoc
- Method WordDocument.LoadLegacyDoc
- Method WordDocumentComparer.Compare
Accepted by parameters
- Constructor WordFluentDocument.WordFluentDocument
- Constructor WordApplicationProperties.WordApplicationProperties
- Constructor WordBackground.WordBackground
- Constructor WordBackground.WordBackground
- Constructor WordBuiltinDocumentProperties.WordBuiltinDocumentProperties
- Constructor WordChart.WordChart
- Method WordComment.Create
- Method WordComment.GetAllComments
- Constructor WordCompatibilitySettings.WordCompatibilitySettings
- Constructor WordCoverPage.WordCoverPage
- Constructor WordCoverPageProperties.WordCoverPageProperties
- Constructor WordCustomProperties.WordCustomProperties
- Extension method WordDocument.AddHeadersAndFooters
- Extension method WordDocument.AddParagraphFromXml
- Extension method WordDocument.Find
- Method WordDocument.AppendDocument
- Method WordDocument.MarkIndexEntriesFromConcordance
- Method WordDocumentComparer.CompareStructure
- Method WordDocumentComparer.CompareStructure
- Method WordDocumentRegexExtensions.Find
- Constructor WordDocumentStatistics.WordDocumentStatistics
- Method WordDocumentTraversal.BuildListIndices
- Method WordDocumentTraversal.BuildListMarkers
- Method WordDocumentTraversal.EnumerateSections
- Constructor WordDocumentVariables.WordDocumentVariables
- Constructor WordEmbeddedDocument.WordEmbeddedDocument
- Constructor WordEmbeddedObject.WordEmbeddedObject
- Method WordFooter.RemoveFooters
- Method WordHeader.RemoveHeaders
- Method WordHeadersAndFooters.AddHeadersAndFooters
- Constructor WordImage.WordImage
- Constructor WordImage.WordImage
- Constructor WordImage.WordImage
- Constructor WordImage.WordImage
- Constructor WordList.WordList
- Constructor WordList.WordList
- Constructor WordList.WordList
- Constructor WordList.WordList
- Method WordList.AddCustomBulletList
- Method WordList.AddCustomBulletList
- Method WordList.AddCustomBulletList
- Method WordList.AddCustomList
- Method WordList.AddPictureBulletList
- Method WordList.AddPictureBulletList
- Method WordListNumbering.CreateNumberingDefinition
- Method WordListNumbering.GetNumberingDefinition
- Method WordMailMerge.Execute
- Method WordMailMerge.ExecuteConditionalBlocks
- Method WordMailMerge.ExecuteContentControlDataBindings
- Method WordMailMerge.ExecuteRepeatingBlockRegions
- Method WordMailMerge.ExecuteRepeatingBlocks
- Method WordMailMerge.ExecuteWithReport
- Method WordMailMerge.InspectTemplate
- Method WordMailMerge.PreflightTemplate
- Method WordMailMerge.RefreshContentControlDataBindings
- Method WordMailMerge.ValidateTemplate
- Method WordMailMerge.ValidateTemplate
- Constructor WordMargins.WordMargins
- Constructor WordPageNumber.WordPageNumber
- Constructor WordPageNumber.WordPageNumber
- Constructor WordPageSizes.WordPageSizes
- Constructor WordParagraph.WordParagraph
- Constructor WordSettings.WordSettings
- Method WordTable.Create
- Constructor WordTableCell.WordTableCell
- Constructor WordTableOfContent.WordTableOfContent
- Constructor WordTableRow.WordTableRow
- Method WordTemplate.Apply
- Method WordTemplate.Apply
- Constructor WordTextBox.WordTextBox
- Constructor WordTextBox.WordTextBox
- Constructor WordTextBox.WordTextBox
- Constructor WordWatermark.WordWatermark
- Constructor WordWatermark.WordWatermark
- Method WordXmlExtensions.AddParagraphFromXml
Constructors
public WordDocument() #Methods
public Void AcceptRevisions(String authorName) #VoidGiven author name, accept all revisions by given Author.
Parameters
- authorName System.String
- Author whose revisions should be accepted.
public WordRevisionOperationReport AcceptRevisions(WordRevisionFilter filter) #WordRevisionOperationReportAccepts revisions that match the provided filter and returns a deterministic operation report.
Parameters
- filter OfficeIMO.Word.WordRevisionFilter
- Filter describing revisions to accept.
public WordRevisionOperationReport AcceptRevisionsInParagraph(WordParagraph paragraph, WordRevisionFilter filter = null) #WordRevisionOperationReportAccepts revisions inside the specified paragraph.
Parameters
- paragraph OfficeIMO.Word.WordParagraph
- Paragraph that scopes the operation.
- filter OfficeIMO.Word.WordRevisionFilter = null
- Optional additional filter.
public WordParagraph AddBookmark(String bookmarkName) #WordParagraphInserts a bookmark in a new paragraph.
Parameters
- bookmarkName System.String
- Name of the bookmark.
Returns
The created WordParagraph.
public WordParagraph AddBreak(Nullable<WordBreakType> breakType = null) #WordParagraphInserts a break into the document.
Parameters
- breakType System.Nullable{OfficeIMO.Word.WordBreakType} = null
- Type of break to insert.
Returns
The created WordParagraph containing the break.
public WordChart AddChart(String title = "", Boolean roundedCorners = false, Int32 width = 600, Int32 height = 600) #WordChartAdds 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 System.String = ""
- The title.
- roundedCorners System.Boolean = false
- if set to true [rounded corners].
- width System.Int32 = 600
- The width.
- height System.Int32 = 600
- The height.
Returns
WordChart
public WordParagraph AddCitation(String sourceTag) #WordParagraphInserts a citation field referencing the specified source tag.
Parameters
- sourceTag System.String
- Tag of the bibliographic source.
Returns
The created WordParagraph.
public WordChart AddComboChart(String title = "", Boolean roundedCorners = false, Int32 width = 600, Int32 height = 600) #WordChartCreates a chart ready for combining bar and line series. Use String>) to supply category labels and then call OfficeColor) or OfficeColor) to add data. The call to AddChartAxisX must be performed before adding any series so both chart types share the same axes.
Parameters
- title System.String = ""
- roundedCorners System.Boolean = false
- width System.Int32 = 600
- height System.Int32 = 600
public WordCoverPage AddCoverPage(WordCoverPageTemplate coverPageTemplate) #WordCoverPageAdds a built-in cover page to the document.
Parameters
- coverPageTemplate OfficeIMO.Word.WordCoverPageTemplate
- Cover page template to use.
Returns
The created WordCoverPage.
public WordList AddCustomBulletList(Char symbol, String fontName, String colorHex, Nullable<Int32> fontSize = null) #WordListAdds a custom bullet list with formatting options.
Parameters
- symbol System.Char
- Bullet symbol.
- fontName System.String
- Font name for the symbol.
- colorHex System.String
- Hex color of the symbol.
- fontSize System.Nullable{System.Int32} = null
- Font size in points.
Returns
The created WordList.
public WordList AddCustomBulletList(WordBulletSymbol symbol, String fontName, Nullable<OfficeColor> color = null, String colorHex = null, Nullable<Int32> fontSize = null) #WordListAdds a custom bullet list with formatting options.
Parameters
- symbol OfficeIMO.Word.WordBulletSymbol
- Bullet symbol.
- fontName System.String
- Font name for the symbol.
- color System.Nullable{OfficeIMO.Drawing.OfficeColor} = null
- Bullet color.
- colorHex System.String = null
- Hex color fallback.
- fontSize System.Nullable{System.Int32} = null
- Font size in points.
Returns
The created WordList.
public WordList AddCustomBulletList(WordListLevelKind kind, String fontName, Nullable<OfficeColor> color = null, String colorHex = null, Nullable<Int32> fontSize = null) #WordListAdds a custom bullet list using the specified formatting.
Parameters
- kind OfficeIMO.Word.WordListLevelKind
- Bullet level kind.
- fontName System.String
- Font name for the bullet.
- color System.Nullable{OfficeIMO.Drawing.OfficeColor} = null
- Bullet color.
- colorHex System.String = null
- Hex color fallback.
- fontSize System.Nullable{System.Int32} = null
- Font size in points.
Returns
The created WordList.
Examples
using WordDocument document = WordDocument.Create(filePath);
WordList list = document.AddCustomBulletList(
WordListLevelKind.BulletSquareSymbol,
"Courier New",
OfficeIMO.Drawing.OfficeColor.Red,
fontSize: 16);
list.AddItem("Custom bullet item");
document.Save();
public WordList AddCustomList() #WordListCreates a custom list with no predefined levels for manual configuration.
Returns
The created WordList.
Examples
using WordDocument document = WordDocument.Create(filePath);
WordList list = document.AddCustomList()
.AddListLevel(1, WordListLevelKind.BulletSquareSymbol, "Courier New", colorHex: "#FF0000", fontSize: 14)
.AddListLevel(5, WordListLevelKind.BulletBlackCircle, "Arial", colorHex: "#00FF00", fontSize: 10);
list.AddItem("First level item");
list.AddItem("Fifth level item", 4);
document.Save();
public WordEmbeddedDocument AddEmbeddedDocument(String fileName, Nullable<WordAlternativeFormatImportPartType> type = null) #WordEmbeddedDocumentEmbeds another document as an alternative format part.
Parameters
- fileName System.String
- Path to the document.
- type System.Nullable{OfficeIMO.Word.WordAlternativeFormatImportPartType} = null
- Optional format part type.
Returns
The created WordEmbeddedDocument.
public WordEmbeddedDocument AddEmbeddedFragment(String htmlContent, WordAlternativeFormatImportPartType type) #WordEmbeddedDocumentEmbeds HTML content as an alternative format part.
Parameters
- htmlContent System.String
- HTML content to embed.
- type OfficeIMO.Word.WordAlternativeFormatImportPartType
- Format part type.
Returns
The created WordEmbeddedDocument.
public WordEmbeddedDocument AddEmbeddedFragmentAfter(WordParagraph paragraph, String htmlContent, WordAlternativeFormatImportPartType type = Html) #WordEmbeddedDocumentInserts an HTML fragment after the specified paragraph.
Parameters
- paragraph OfficeIMO.Word.WordParagraph
- Paragraph after which the fragment should be inserted.
- htmlContent System.String
- HTML content to insert.
- type OfficeIMO.Word.WordAlternativeFormatImportPartType = Html
- Optional format type of the fragment.
Returns
The created WordEmbeddedDocument.
public WordParagraph AddEmbeddedObject(String filePath, String imageFilePath, Nullable<Double> width = null, Nullable<Double> height = null) #WordParagraphEmbeds an object with a preview image.
Parameters
- filePath System.String
- Path to the object file.
- imageFilePath System.String
- Preview image path.
- width System.Nullable{System.Double} = null
- Optional width in points.
- height System.Nullable{System.Double} = null
- Optional height in points.
Returns
The paragraph containing the embedded object.
public WordParagraph AddEmbeddedObject(String filePath, WordEmbeddedObjectOptions options) #WordParagraphEmbeds an object with custom options.
Parameters
- filePath System.String
- Path to the object file.
- options OfficeIMO.Word.WordEmbeddedObjectOptions
- Embedding options.
Returns
The paragraph containing the embedded object.
public Void AddEndnoteProperties(Nullable<WordNumberFormat> numberingFormat = null, Nullable<WordEndnotePosition> position = null, Nullable<WordNoteNumberRestart> restartNumbering = null, Nullable<Int32> startNumber = null) #VoidAdds or updates endnote configuration for the first section.
Parameters
- numberingFormat System.Nullable{OfficeIMO.Word.WordNumberFormat} = null
- Numbering format to apply.
- position System.Nullable{OfficeIMO.Word.WordEndnotePosition} = null
- Location of endnotes.
- restartNumbering System.Nullable{OfficeIMO.Word.WordNoteNumberRestart} = null
- Restart numbering option.
- startNumber System.Nullable{System.Int32} = null
- Starting number.
public WordParagraph AddEquation(OfficeMathExpression expression) #WordParagraphAdds an editable Word equation authored with the reusable OfficeIMO math model.
Parameters
- arg1 OfficeIMO.Drawing.OfficeMathExpression
public WordParagraph AddEquation(String omml) #WordParagraphInserts an equation specified in OMML format.
Parameters
- omml System.String
- OMML markup for the equation.
Returns
The created WordParagraph.
public WordParagraph AddField(WordFieldType wordFieldType, Nullable<WordFieldFormat> wordFieldFormat = null, String customFormat = null, Boolean advanced = false, List<String> parameters = null) #WordParagraphAdds a field to the document in a new paragraph.
Parameters
- wordFieldType OfficeIMO.Word.WordFieldType
- Type of field to insert.
- wordFieldFormat System.Nullable{OfficeIMO.Word.WordFieldFormat} = null
- Optional field format.
- customFormat System.String = null
- Custom format string for date or time fields.
- advanced System.Boolean = false
- Whether to use advanced formatting.
- parameters System.Collections.Generic.List{System.String} = null
- Additional switch parameters.
Returns
The created WordParagraph.
public WordParagraph AddField(WordFieldCode fieldCode, Nullable<WordFieldFormat> wordFieldFormat = null, String customFormat = null, Boolean advanced = false) #WordParagraphAdds a field represented by a WordFieldCode to the document in a new paragraph.
Parameters
- fieldCode OfficeIMO.Word.WordFieldCode
- Field code instance describing instructions and switches.
- wordFieldFormat System.Nullable{OfficeIMO.Word.WordFieldFormat} = null
- Optional field format.
- customFormat System.String = null
- Custom format string for date or time fields.
- advanced System.Boolean = false
- Whether to use advanced formatting.
Returns
The created WordParagraph.
public WordParagraph AddField(WordFieldBuilder builder, Boolean advanced = false) #WordParagraphAdds a field built using WordFieldBuilder.
Parameters
- builder OfficeIMO.Word.WordFieldBuilder
- Field builder instance.
- advanced System.Boolean = false
- Whether to use advanced formatting.
Returns
The created WordParagraph.
public Void AddFootnoteProperties(Nullable<WordNumberFormat> numberingFormat = null, Nullable<WordFootnotePosition> position = null, Nullable<WordNoteNumberRestart> restartNumbering = null, Nullable<Int32> startNumber = null) #VoidAdds or updates footnote configuration for the first section.
Parameters
- numberingFormat System.Nullable{OfficeIMO.Word.WordNumberFormat} = null
- Numbering format to apply.
- position System.Nullable{OfficeIMO.Word.WordFootnotePosition} = null
- Location of footnotes.
- restartNumbering System.Nullable{OfficeIMO.Word.WordNoteNumberRestart} = null
- Restart numbering option.
- startNumber System.Nullable{System.Int32} = null
- Starting number.
public WordParagraph AddHorizontalLine(Nullable<WordBorderStyle> lineType = null, Nullable<OfficeColor> color = null, UInt32 size = 12, UInt32 space = 1) #WordParagraphInserts a horizontal line into the document.
Parameters
- lineType System.Nullable{OfficeIMO.Word.WordBorderStyle} = null
- Border style of the line.
- color System.Nullable{OfficeIMO.Drawing.OfficeColor} = null
- Line color.
- size System.UInt32 = 12
- Line width in eighths of a point.
- space System.UInt32 = 1
- Space above and below the line.
Returns
The paragraph containing the line.
public WordParagraph AddHyperLink(String text, Uri uri, Boolean addStyle = false, String tooltip = "", Boolean history = true) #WordParagraphAdds a hyperlink pointing to an external URI.
Parameters
- text System.String
- Display text for the hyperlink.
- uri System.Uri
- Target URI.
- addStyle System.Boolean = false
- Whether to apply hyperlink style.
- tooltip System.String = ""
- Tooltip for the hyperlink.
- history System.Boolean = true
- Whether to track link history.
Returns
The created WordParagraph.
public WordParagraph AddHyperLink(String text, String anchor, Boolean addStyle = false, String tooltip = "", Boolean history = true) #WordParagraphAdds an internal hyperlink pointing to a bookmark.
Parameters
- text System.String
- Display text for the hyperlink.
- anchor System.String
- Bookmark anchor.
- addStyle System.Boolean = false
- Whether to apply hyperlink style.
- tooltip System.String = ""
- Tooltip for the hyperlink.
- history System.Boolean = true
- Whether to track link history.
Returns
The created WordParagraph.
public async Task<WordImage> AddImageFromUrlAsync(String url, Nullable<Double> width = null, Nullable<Double> height = null, CancellationToken cancellationToken = null) #Task<WordImage>Downloads an image from the specified URL and inserts it into the document.
Parameters
- url System.String
- URL of the image to download.
- width System.Nullable{System.Double} = null
- Optional width for the image.
- height System.Nullable{System.Double} = null
- Optional height for the image.
- cancellationToken System.Threading.CancellationToken = null
- Token used to cancel the remote request.
Returns
The created WordImage.
public Task<WordImage> AddImageFromUrlAsync(String url, Nullable<Double> width, Nullable<Double> height, OfficeRemoteImageLoadOptions remoteImageOptions, CancellationToken cancellationToken = null) #Task<WordImage>Downloads an image with explicit remote-network policy and inserts it into the document.
Parameters
- url System.String
- width System.Nullable{System.Double}
- height System.Nullable{System.Double}
- remoteImageOptions OfficeIMO.Drawing.OfficeRemoteImageLoadOptions
- cancellationToken System.Threading.CancellationToken = null
public WordImage AddImageVml(String filePathImage, Nullable<Double> width = null, Nullable<Double> height = null) #WordImageInserts a VML image into the document.
Parameters
- filePathImage System.String
- width System.Nullable{System.Double} = null
- height System.Nullable{System.Double} = null
public WordList AddList(WordListStyle style) #WordListCreates a list using one of the built-in numbering styles. For manually configured lists prefer AddCustomList.
Parameters
- style OfficeIMO.Word.WordListStyle
public WordList AddListBulleted() #WordListAdds a bulleted list using the default bulleted style.
Returns
The created WordList.
public WordList AddListNumbered() #WordListAdds a numbered list using the default numbering style.
Returns
The created WordList.
public Void AddMacro(String filePath) #VoidAdds a VBA project to the document.
Parameters
- filePath System.String
- Path to a vbaProject.bin file.
public Void AddMacro(Byte[] data) #VoidAdds a VBA project to the document from bytes.
Parameters
- data System.Byte[]
- VBA project data.
public Void AddMacro(Stream stream, Nullable<Int64> maxBytes = null) #VoidAdds or replaces a VBA project from a readable stream.
Parameters
- stream System.IO.Stream
- Stream containing vbaProject.bin.
- maxBytes System.Nullable{System.Int64} = null
- Optional maximum number of bytes accepted from the stream.
public WordParagraph AddPageBreak() #WordParagraphInserts a page break into the document.
Returns
The created WordParagraph representing the page break.
public Void AddPageNumbering(Nullable<Int32> startNumber = null, Nullable<WordNumberFormat> format = null) #VoidAdds or updates page numbering for the first section.
Parameters
- startNumber System.Nullable{System.Int32} = null
- Starting page number.
- format System.Nullable{OfficeIMO.Word.WordNumberFormat} = null
- Number format.
public WordParagraph AddParagraph(WordParagraph wordParagraph = null) #WordParagraphAppends a paragraph to the document body.
Parameters
- wordParagraph OfficeIMO.Word.WordParagraph = null
- Optional paragraph to append. When null a new paragraph is created.
Returns
The added WordParagraph instance.
public WordParagraph AddParagraph(String text) #WordParagraphAdds a new paragraph containing the specified text.
Parameters
- text System.String
- Text for the paragraph.
Returns
The created WordParagraph.
public WordList AddPictureBulletList(Stream imageStream, String fileName) #WordListCreates a bullet list where the bullet symbol is provided as an image.
Parameters
- imageStream System.IO.Stream
- Stream containing the image data.
- fileName System.String
- File name used to determine the image type.
Returns
The created WordList.
public WordRepeatingSection AddRepeatingSection(String sectionTitle = null, String alias = null, String tag = null) #WordRepeatingSectionAdds a new paragraph with a repeating section content control.
Parameters
- sectionTitle System.String = null
- Optional title of the repeating section.
- alias System.String = null
- Optional alias for the control.
- tag System.String = null
- Optional tag for the control.
Returns
The created WordRepeatingSection.
public WordSection AddSection(WordSectionBreakType breakType) #WordSectionAdds a new section using the specified OfficeIMO break type.
Parameters
- breakType OfficeIMO.Word.WordSectionBreakType
- Section break type.
Returns
The created WordSection.
public WordSection AddSection() #WordSectionAdds a new section using the document default break behavior.
Returns
The created WordSection.
public WordShape AddShape(WordShapeType shapeType, Double widthPt, Double heightPt, String fillColor = "#FFFFFF", String strokeColor = "#000000", Double strokeWeightPt = 1, Double arcSize = 0.25) #WordShapeAdds a basic shape to the document in a new paragraph.
Parameters
- shapeType OfficeIMO.Word.WordShapeType
- Type of shape to create.
- widthPt System.Double
- Width in points or line end X.
- heightPt System.Double
- Height in points or line end Y.
- fillColor System.String = "#FFFFFF"
- Fill color in hex format.
- strokeColor System.String = "#000000"
- Stroke color in hex format.
- strokeWeightPt System.Double = 1
- Stroke weight in points.
- arcSize System.Double = 0.25
- Corner roundness fraction for rounded rectangles.
Returns
The created WordShape.
public WordShape AddShape(WordShapeType shapeType, Double widthPt, Double heightPt, OfficeColor fillColor, OfficeColor strokeColor, Double strokeWeightPt = 1, Double arcSize = 0.25) #WordShapeAdds a basic shape to the document using OfficeColor values.
Parameters
- arg1 OfficeIMO.Word.WordShapeType
- arg2 System.Double
- arg3 System.Double
- arg4 OfficeIMO.Drawing.OfficeColor
- arg5 OfficeIMO.Drawing.OfficeColor
- arg6 System.Double = 1
- arg7 System.Double = 0.25
public WordShape AddShapeDrawing(WordShapeType shapeType, Double widthPt, Double heightPt) #WordShapeAdds a DrawingML shape to the document in a new paragraph.
Parameters
- shapeType OfficeIMO.Word.WordShapeType
- Type of shape to create.
- widthPt System.Double
- Width in points.
- heightPt System.Double
- Height in points.
public WordShape AddShapeDrawing(WordShapeType shapeType, Double widthPt, Double heightPt, Double leftPt, Double topPt) #WordShapeAdds a DrawingML shape anchored at an absolute position on the page in a new paragraph.
Parameters
- shapeType OfficeIMO.Word.WordShapeType
- widthPt System.Double
- heightPt System.Double
- leftPt System.Double
- topPt System.Double
public WordSmartArt AddSmartArt(WordSmartArtType type) #WordSmartArtInserts a SmartArt diagram into the document.
Parameters
- type OfficeIMO.Word.WordSmartArtType
- Layout type of the SmartArt.
Returns
The created WordSmartArt instance.
public WordStructuredDocumentTag AddStructuredDocumentTag(String text, String alias = null, String tag = null) #WordStructuredDocumentTagAdds a new paragraph with a content control (structured document tag).
Parameters
- text System.String
- Initial text of the control.
- alias System.String = null
- Optional alias for the control.
- tag System.String = null
- Optional tag for the control.
Returns
The created WordStructuredDocumentTag.
public WordTable AddTable(Int32 rows, Int32 columns, WordTableStyle tableStyle = TableGrid) #WordTableAdds a table to the end of the document body.
Parameters
- rows System.Int32
- Number of rows to create.
- columns System.Int32
- Number of columns to create.
- tableStyle OfficeIMO.Word.WordTableStyle = TableGrid
- Optional table style to apply.
Returns
The inserted WordTable instance.
public WordTable AddTableFromObjects(IEnumerable<Object> items, WordTableStyle style = TableGrid, Boolean includeHeader = true, Nullable<WordTableLayoutMode> layout = null) #WordTableAdds a table based on a sequence of objects by projecting properties or dictionary keys into columns.
Parameters
- items System.Collections.Generic.IEnumerable{System.Object}
- Objects to insert into the table.
- style OfficeIMO.Word.WordTableStyle = TableGrid
- Table style to apply.
- includeHeader System.Boolean = true
- Whether to include a header row.
- layout System.Nullable{OfficeIMO.Word.WordTableLayoutMode} = null
- Optional table layout (Autofit or Fixed).
Returns
The created WordTable.
public WordTableOfContent AddTableOfContent(WordTableOfContentsStyle tableOfContentStyle = Template1, Int32 minLevel = 1, Int32 maxLevel = 3) #WordTableOfContentAdds a table of contents to the current document.
Parameters
- tableOfContentStyle OfficeIMO.Word.WordTableOfContentsStyle = Template1
- Optional style to use when creating the table of contents.
- minLevel System.Int32 = 1
- Minimum heading level to include (1..9).
- maxLevel System.Int32 = 3
- Maximum heading level to include (1..9).
Returns
The created WordTableOfContent instance.
public WordList AddTableOfContentList(WordListStyle style) #WordListCreates a list configured for a table of contents.
Parameters
- style OfficeIMO.Word.WordListStyle
- Numbering style to apply.
Returns
The created WordList.
public WordTextBox AddTextBox(String text, WordImageTextWrapping wrapTextImage = Square) #WordTextBoxInserts a text box into the document.
Parameters
- text System.String
- Initial text for the text box.
- wrapTextImage OfficeIMO.Word.WordImageTextWrapping = Square
- Text wrapping option.
Returns
The created WordTextBox.
public WordTextBox AddTextBoxVml(String text) #WordTextBoxInserts a VML text box into the document.
Parameters
- text System.String
public static WordDocumentConversionReport AnalyzeConversion(String sourcePath, String destinationPath, WordDocumentConversionOptions options = null) #WordDocumentConversionReportAnalyzes a file-to-file Word conversion without creating or changing an artifact.
Parameters
- sourcePath System.String
- destinationPath System.String
- options OfficeIMO.Word.WordDocumentConversionOptions = null
public static async Task<WordDocumentConversionReport> AnalyzeConversionAsync(String sourcePath, String destinationPath, WordDocumentConversionOptions options = null, CancellationToken cancellationToken = null) #Task<WordDocumentConversionReport>Asynchronously analyzes a file-to-file Word conversion without creating or changing an artifact.
Parameters
- sourcePath System.String
- destinationPath System.String
- options OfficeIMO.Word.WordDocumentConversionOptions = null
- cancellationToken System.Threading.CancellationToken = null
public Void AppendDocument(WordDocument source) #VoidAppends the content of another WordDocument to this document.
Parameters
- source OfficeIMO.Word.WordDocument
- The document to append.
public WordFluentDocument AsFluent() #WordFluentDocumentCreates a fluent wrapper for this document.
Returns
A new WordFluentDocument instance.
public LegacyDocWriteAssessment AssessLegacyDocWrite(WordSaveOptions options = null) #LegacyDocWriteAssessmentRuns 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 WordSaveOptions).
Parameters
- options OfficeIMO.Word.WordSaveOptions = null
public Int32 CleanupDocument(WordDocumentCleanupOptions options = All) #Int32This 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
public WordSection CloneSection(Int32 index) #WordSectionClones the section at the specified index and inserts the clone after it.
Parameters
- index System.Int32
- Zero based index of the section to clone.
Returns
The cloned WordSection.
public static WordDocumentConversionResult Convert(String sourcePath, String destinationPath, WordDocumentConversionOptions options = null) #WordDocumentConversionResultConverts a Word file between DOC and DOCX and returns format and fidelity diagnostics.
Parameters
- sourcePath System.String
- Path to the source DOC or DOCX file.
- destinationPath System.String
- Path to the destination DOC or DOCX file.
- options OfficeIMO.Word.WordDocumentConversionOptions = null
- Optional conversion policy settings.
Returns
The completed conversion result.
public static async Task<WordDocumentConversionResult> ConvertAsync(String sourcePath, String destinationPath, WordDocumentConversionOptions options = null, CancellationToken cancellationToken = null) #Task<WordDocumentConversionResult>Asynchronously converts a Word file between DOC and DOCX.
Parameters
- sourcePath System.String
- Path to the source DOC or DOCX file.
- destinationPath System.String
- Path to the destination DOC or DOCX file.
- options OfficeIMO.Word.WordDocumentConversionOptions = null
- Optional conversion policy settings.
- cancellationToken System.Threading.CancellationToken = null
- Cancellation token.
Returns
The completed conversion result.
public Void ConvertRevisionsToMarkup() #VoidConverts 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.
public static WordDocument Create(WordCreateOptions options = null) #WordDocumentCreate a new WordDocument
Parameters
- options OfficeIMO.Word.WordCreateOptions = null
- Creation options. SaveOnDispose is invalid without an associated destination.
public static WordDocument Create(String filePath, WordCreateOptions options = null) #WordDocumentCreates a Word document associated with a path that is written on explicit save.
Parameters
- filePath System.String
- Destination associated with the document.
- options OfficeIMO.Word.WordCreateOptions = null
- Creation and persistence options.
public static WordDocument Create(Stream stream, WordCreateOptions options = null) #WordDocumentCreate a new WordDocument writing directly to the provided stream.
Parameters
- stream System.IO.Stream
- Destination stream.
- options OfficeIMO.Word.WordCreateOptions = null
- Creation and persistence options.
Returns
Instance of WordDocument.
Exceptions
ArgumentNullExceptionโ Thrown when stream is null.
public WordDocumentSnapshot CreateInspectionSnapshot() #WordDocumentSnapshotpublic WordListNumbering CreateNumberingDefinition() #WordListNumberingCreates a numbering definition that can be customized and reused.
Returns
The created WordListNumbering.
public WordTable CreateTable(Int32 rows, Int32 columns, WordTableStyle tableStyle = TableGrid) #WordTableCreates a table without inserting it into the document.
Parameters
- rows System.Int32
- Number of rows to create.
- columns System.Int32
- Number of columns to create.
- tableStyle OfficeIMO.Word.WordTableStyle = TableGrid
- Optional table style to apply.
Returns
The newly created WordTable.
public WordDocumentVisualSnapshot CreateVisualSnapshot(WordImageExportOptions options = null) #WordDocumentVisualSnapshotCreates a format-neutral visual snapshot for the requested document page.
Parameters
- options OfficeIMO.Word.WordImageExportOptions = null
public IReadOnlyList<WordDocumentVisualSnapshot> CreateVisualSnapshots(WordImageExportOptions options = null) #IReadOnlyList<WordDocumentVisualSnapshot>Creates format-neutral visual snapshots for a page range or the complete document.
Parameters
- options OfficeIMO.Word.WordImageExportOptions = null
public IReadOnlyList<WordDocumentVisualSnapshot> CreateVisualSnapshots(WordImageExportOptions options, CancellationToken cancellationToken) #IReadOnlyList<WordDocumentVisualSnapshot>Creates format-neutral visual snapshots for a page range or the complete document with cooperative cancellation during pagination.
Parameters
- options OfficeIMO.Word.WordImageExportOptions
- cancellationToken System.Threading.CancellationToken
public virtual Void Dispose() #VoidReleases resources associated with this WordDocument instance.
public virtual async ValueTask DisposeAsync() #ValueTaskReleases resources associated with the document asynchronously.
public Void EmbedFont(String fontPath) #VoidEmbeds a font into the document.
Parameters
- fontPath System.String
- Path to a TrueType/OpenType font file.
public Void EmbedFont(String fontPath, String styleId, String styleName = null) #VoidEmbeds a font and registers a paragraph style using that font.
Parameters
- fontPath System.String
- Path to a TrueType/OpenType font file.
- styleId System.String
- Style identifier to register.
- styleName System.String = null
- Optional friendly name for the style.
public OfficeImageExportResult ExportImage(OfficeImageExportFormat format, WordImageExportOptions options = null, CancellationToken cancellationToken = null) #OfficeImageExportResultExports the requested document page as a supported raster format or SVG.
Parameters
- format OfficeIMO.Drawing.OfficeImageExportFormat
- options OfficeIMO.Word.WordImageExportOptions = null
- cancellationToken System.Threading.CancellationToken = null
public IReadOnlyList<OfficeImageExportResult> ExportImages(OfficeImageExportFormat format, WordImageExportOptions options = null) #IReadOnlyList<OfficeImageExportResult>Exports a page range or the complete document as PNG or SVG images.
Parameters
- format OfficeIMO.Drawing.OfficeImageExportFormat
- options OfficeIMO.Word.WordImageExportOptions = null
public Void ExportImages(OfficeImageExportFormat format, OfficeImageExportConsumer consumer, WordImageExportOptions options = null, CancellationToken cancellationToken = null) #VoidStreams selected page images to a consumer without retaining earlier payloads.
Parameters
- format OfficeIMO.Drawing.OfficeImageExportFormat
- consumer OfficeIMO.Drawing.OfficeImageExportConsumer
- options OfficeIMO.Word.WordImageExportOptions = null
- cancellationToken System.Threading.CancellationToken = null
public Dictionary<String, Object> ExtractContentControlValues(WordContentControlFormKey keyMode = TagThenAlias) #Dictionary<String, Object>Extracts values from supported content controls into a form map keyed by tag or alias.
Parameters
- keyMode OfficeIMO.Word.WordContentControlFormKey = TagThenAlias
- Controls which metadata field is used as the map key.
Returns
Extracted form values.
public Byte[] ExtractEmbeddedPayload(String id, Nullable<Int64> maxBytes = null) #Byte[]Extracts an embedded payload by its package-local id.
Parameters
- id System.String
- Id returned by Boolean).
- maxBytes System.Nullable{System.Int64} = null
- Optional extraction limit.
public Byte[] ExtractMacros() #Byte[]Extracts the VBA project as a byte array.
Returns
Byte array with macro content or null when no macros are present.
public Byte[] ExtractMacros(Int64 maxBytes) #Byte[]Extracts a VBA project while enforcing a maximum byte count.
Parameters
- maxBytes System.Int64
public Int32 FillContentControlValues(IReadOnlyDictionary<String, Object> values, WordContentControlFormKey keyMode = TagThenAlias) #Int32Fills supported content controls from a form map keyed by tag or alias.
Parameters
- values System.Collections.Generic.IReadOnlyDictionary{System.String,System.Object}
- Values to apply.
- keyMode OfficeIMO.Word.WordContentControlFormKey = TagThenAlias
- Controls which metadata field is used as the map key.
Returns
The number of controls updated.
public List<WordParagraph> Find(String text, StringComparison stringComparison = OrdinalIgnoreCase) #List<WordParagraph>Searches the document for paragraphs containing the specified text.
Parameters
- text System.String
- Text to search for.
- stringComparison System.StringComparison = OrdinalIgnoreCase
- Comparison rules for the search.
Returns
A list of found WordParagraph instances.
public Int32 FindAndReplace(String textToFind, String textToReplace, StringComparison stringComparison = OrdinalIgnoreCase) #Int32FindAdnReplace from the whole doc
Parameters
- textToFind System.String
- textToReplace System.String
- stringComparison System.StringComparison = OrdinalIgnoreCase
public static Int32 FindAndReplace(List<WordParagraph> paragraphs, String textToFind, String textToReplace, StringComparison stringComparison = OrdinalIgnoreCase) #Int32FindAdnReplace from the range parparagraphs
Parameters
- paragraphs System.Collections.Generic.List{OfficeIMO.Word.WordParagraph}
- textToFind System.String
- textToReplace System.String
- stringComparison System.StringComparison = OrdinalIgnoreCase
public WordCheckBox GetCheckBoxByAlias(String alias) #WordCheckBoxRetrieves a checkbox control by its alias.
Parameters
- alias System.String
- Alias of the checkbox.
Returns
The matching WordCheckBox or null.
public WordCheckBox GetCheckBoxByTag(String tag) #WordCheckBoxRetrieves a checkbox control by its tag value.
Parameters
- tag System.String
- Tag value of the checkbox.
Returns
The matching WordCheckBox or null.
public WordComboBox GetComboBoxByAlias(String alias) #WordComboBoxRetrieves a combo box control by its alias.
Parameters
- alias System.String
public WordComboBox GetComboBoxByTag(String tag) #WordComboBoxRetrieves a combo box control by its tag value.
Parameters
- tag System.String
public WordDatePicker GetDatePickerByAlias(String alias) #WordDatePickerRetrieves a date picker control by its alias.
Parameters
- alias System.String
- Alias of the date picker.
Returns
The matching WordDatePicker or null.
public WordDatePicker GetDatePickerByTag(String tag) #WordDatePickerRetrieves a date picker control by its tag value.
Parameters
- tag System.String
- Tag value of the date picker.
Returns
The matching WordDatePicker or null.
public String GetDocumentVariable(String name) #StringGets the value of a document variable or null if the variable does not exist.
Parameters
- name System.String
- Variable name.
public IReadOnlyDictionary<String, String> GetDocumentVariables() #IReadOnlyDictionary<String, String>Returns a read-only view of all document variables.
public WordDropDownList GetDropDownListByAlias(String alias) #WordDropDownListRetrieves a dropdown list control by its alias.
Parameters
- alias System.String
- Alias of the dropdown list.
Returns
The matching WordDropDownList or null.
public WordDropDownList GetDropDownListByTag(String tag) #WordDropDownListRetrieves a dropdown list control by its tag value.
Parameters
- tag System.String
- Tag value of the dropdown list.
Returns
The matching WordDropDownList or null.
public IReadOnlyList<OfficeEmbeddedPayloadInfo> GetEmbeddedPayloads(Boolean includeSha256 = false) #IReadOnlyList<OfficeEmbeddedPayloadInfo>Gets embedded package, OLE, and ActiveX payload metadata.
Parameters
- includeSha256 System.Boolean = false
- Whether to calculate a digest for every payload.
public Int32 GetEstimatedImagePageCount() #Int32Estimates how many pages the dependency-free image renderer will produce for this document.
public Int32 GetEstimatedPageCount() #Int32Returns the renderer's estimated document page count.
public WordHeader GetHeaderForSection(Int32 sectionIndex = -1) #WordHeaderReturns the default header for a specific section index.
Parameters
- sectionIndex System.Int32 = -1
- Index of the section or -1 for the last section.
public IReadOnlyList<Byte[]> GetImageBytes() #IReadOnlyList<Byte[]>Returns the bytes of all embedded images in the document. Images linked externally are skipped.
public WordListNumbering GetNumberingDefinition(Int32 abstractNumberId) #WordListNumberingRetrieves a numbering definition by its identifier.
Parameters
- abstractNumberId System.Int32
- Identifier of the numbering definition.
Returns
The WordListNumbering if found; otherwise, null.
public WordPictureControl GetPictureControlByAlias(String alias) #WordPictureControlRetrieves a picture control by its alias.
Parameters
- alias System.String
public WordPictureControl GetPictureControlByTag(String tag) #WordPictureControlRetrieves a picture control by its tag value.
Parameters
- tag System.String
public WordRepeatingSection GetRepeatingSectionByAlias(String alias) #WordRepeatingSectionRetrieves a repeating section control by its alias.
Parameters
- alias System.String
public WordRepeatingSection GetRepeatingSectionByTag(String tag) #WordRepeatingSectionRetrieves a repeating section control by its tag value.
Parameters
- tag System.String
public WordStructuredDocumentTag GetStructuredDocumentTagByAlias(String alias) #WordStructuredDocumentTagRetrieves a structured document tag by its alias.
Parameters
- alias System.String
- Alias of the control.
Returns
The matching WordStructuredDocumentTag or null.
public WordStructuredDocumentTag GetStructuredDocumentTagByTag(String tag) #WordStructuredDocumentTagRetrieves a structured document tag by its tag value.
Parameters
- tag System.String
- Tag value of the control.
Returns
The matching WordStructuredDocumentTag or null.
public WordParagraph InsertParagraphAt(Int32 index, WordParagraph paragraph = null) #WordParagraphInserts a paragraph at the specified index within the body.
Parameters
- index System.Int32
- Zero-based position at which to insert the paragraph.
- paragraph OfficeIMO.Word.WordParagraph = null
- Optional paragraph to insert. When null a new paragraph is created.
Returns
The inserted WordParagraph.
public WordTable InsertTableAfter(WordParagraph anchor, WordTable table) #WordTableInserts an existing table after the provided paragraph.
Parameters
- anchor OfficeIMO.Word.WordParagraph
- Paragraph after which the table will be inserted.
- table OfficeIMO.Word.WordTable
- Table instance to insert.
Returns
The inserted WordTable.
public WordFeatureReport InspectFeatures() #WordFeatureReportInspects document features and reports which ones OfficeIMO can edit, partially edit, preserve, or does not support yet.
public IReadOnlyList<WordFieldInfo> InspectFields() #IReadOnlyList<WordFieldInfo>Inspects simple and complex Word fields across the main document, headers, footers, footnotes and endnotes.
Returns
A deterministic read-only field inventory with raw instructions, parsed tokens, result text and location metadata.
public static WordMacroProjectSignatureInfo InspectMacroProjectSignatures(String filePath, WordMacroProjectSignatureInspectionOptions options = null) #WordMacroProjectSignatureInfoInspects VBA project and signature-part metadata cross-platform without claiming that the signatures bind to the current macro project. Use WordMacroProjectSignatureValidationOptions) for Microsoft Office SIP content-binding validation.
Parameters
- filePath System.String
- Path to a saved DOCM or DOTM package.
- options OfficeIMO.Word.WordMacroProjectSignatureInspectionOptions = null
- Optional package, signature, CMS, trust, revocation, and timestamp policy.
public static WordMacroProjectSignatureInfo InspectMacroProjectSignatures(String filePath, IOfficeSecurityProvider securityProvider, WordMacroProjectSignatureInspectionOptions options = null) #WordMacroProjectSignatureInfoInspects VBA project and signature-part metadata and evaluates CMS, certificate, revocation, and timestamp evidence through an explicitly supplied security provider.
Parameters
- filePath System.String
- Path to a saved DOCM or DOTM package.
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- Cryptographic provider supplied by the optional OfficeIMO.Security package.
- options OfficeIMO.Word.WordMacroProjectSignatureInspectionOptions = null
- Optional package, signature, CMS, trust, revocation, and timestamp policy.
public static OfficePackageSignatureInfo InspectPackageSignatures(String filePath, OfficePackageSignatureInspectionOptions options = null) #OfficePackageSignatureInfoInspects a saved DOCX/DOCM package through the shared dependency-light OPC signature engine.
Parameters
- filePath System.String
- options OfficeIMO.Security.OfficePackageSignatureInspectionOptions = null
public WordReviewInfo InspectReview() #WordReviewInfoInspects comments, comment thread metadata, and tracked revisions without mutating the document.
public WordReviewReport InspectReviewReport(params WordRevisionOperationReport[] actions) #WordReviewReportCreates a structured review report for comments, tracked revisions, unsupported review metadata, and optional accept/reject actions.
Parameters
- actions OfficeIMO.Word.WordRevisionOperationReport[]
- Optional accept/reject operation reports to include in the report.
public WordSignatureInfo InspectSignatures() #WordSignatureInfoInspects package-level digital-signature metadata without copying the encoded package or validating digests and cryptographic trust. Use WordSignatureValidationOptions) for transform-aware digest and trust validation.
public OfficeVbaProjectInfo InspectVbaProject(Boolean includeSha256 = false) #OfficeVbaProjectInfoInspects the attached VBA project without executing macro code.
Parameters
- includeSha256 System.Boolean = false
- Whether to calculate the project SHA-256 digest.
Returns
Project metadata, or null when the document has no VBA project.
public OfficeVbaProjectInfo InspectVbaProject(Boolean includeSha256, Int64 maxBytes) #OfficeVbaProjectInfoInspects the attached VBA project while enforcing a decoded byte limit.
Parameters
- includeSha256 System.Boolean
- Whether to calculate the project SHA-256 digest.
- maxBytes System.Int64
- Maximum decoded VBA project bytes accepted.
Returns
Project metadata, or null when the document has no VBA project.
public static OfficeVbaSignatureInfo InspectVbaSignatures(String filePath, OfficeVbaSignatureInspectionOptions options = null) #OfficeVbaSignatureInfoInspects VBA signatures through the package-neutral core shared with Excel and PowerPoint.
Parameters
- filePath System.String
- options OfficeIMO.Security.OfficeVbaSignatureInspectionOptions = null
public static WordDocument Load(String filePath, WordLoadOptions options = null) #WordDocumentLoad WordDocument from filePath
Parameters
- filePath System.String
- options OfficeIMO.Word.WordLoadOptions = null
- Access, persistence, style, and low-level package options.
Exceptions
FileNotFoundException
public static WordDocument Load(Stream stream, WordLoadOptions options = null) #WordDocumentLoad WordDocument from stream
Parameters
- stream System.IO.Stream
- Readable source. Editable writable seekable sources become the associated destination; other sources remain detached.
- options OfficeIMO.Word.WordLoadOptions = null
- Access, persistence, style, and low-level package options.
public static async Task<WordDocument> LoadAsync(String filePath, WordLoadOptions options = null, CancellationToken cancellationToken = null) #Task<WordDocument>Asynchronously loads a WordDocument from the given file.
Parameters
- filePath System.String
- Path to the file.
- options OfficeIMO.Word.WordLoadOptions = null
- Access, persistence, style, and low-level package options.
- cancellationToken System.Threading.CancellationToken = null
- Cancellation token.
Returns
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 = null) #Task<WordDocument>Asynchronously loads a Word document from a readable stream.
Parameters
- stream System.IO.Stream
- Stream containing DOC or DOCX content.
- options OfficeIMO.Word.WordLoadOptions = null
- Access, persistence, style, and low-level package options.
- cancellationToken System.Threading.CancellationToken = null
- Cancellation token.
Returns
The loaded document. The caller retains ownership of stream.
public static WordDocument LoadEncrypted(String filePath, String password, WordLoadOptions options = null) #WordDocumentLoads a password-encrypted Office Open XML Word document.
Parameters
- filePath System.String
- Path to the encrypted document.
- password System.String
- Password used to decrypt the document package.
- options OfficeIMO.Word.WordLoadOptions = null
- Access and load options. SaveOnDispose is not supported for encrypted sources.
Returns
Loaded WordDocument instance.
public static WordDocument LoadEncrypted(Stream stream, String password, WordLoadOptions options = null) #WordDocumentLoads a password-encrypted Office Open XML Word document from a stream.
Parameters
- stream System.IO.Stream
- Readable stream containing the encrypted document.
- password System.String
- Password used to decrypt the document package.
- options OfficeIMO.Word.WordLoadOptions = null
- Access and load options. SaveOnDispose is not supported for encrypted sources.
Returns
Loaded WordDocument instance.
public static WordDocument LoadLegacyDoc(String path, LegacyDocImportOptions options = null) #WordDocumentLoads a legacy binary `.doc` document and projects supported content into a normal OfficeIMO Word document. The resulting document saves through the normal Open XML path.
Parameters
- path System.String
- options OfficeIMO.Word.LegacyDoc.LegacyDocImportOptions = null
public static WordDocument LoadLegacyDoc(Stream stream, LegacyDocImportOptions options = null) #WordDocumentLoads a legacy binary `.doc` stream and projects supported content into a normal OfficeIMO Word document. The resulting document saves through the normal Open XML path.
Parameters
- stream System.IO.Stream
- options OfficeIMO.Word.LegacyDoc.LegacyDocImportOptions = null
public static LegacyDocLoadResult LoadLegacyDocWithReport(String path, LegacyDocImportOptions options = null) #LegacyDocLoadResultLoads a legacy binary `.doc` document and returns both the projected OfficeIMO document and import report.
Parameters
- path System.String
- options OfficeIMO.Word.LegacyDoc.LegacyDocImportOptions = null
public static LegacyDocLoadResult LoadLegacyDocWithReport(Stream stream, LegacyDocImportOptions options = null) #LegacyDocLoadResultLoads a legacy binary `.doc` stream and returns both the projected OfficeIMO document and import report.
Parameters
- stream System.IO.Stream
- options OfficeIMO.Word.LegacyDoc.LegacyDocImportOptions = null
public WordIndexConcordanceReport MarkIndexEntries(IEnumerable<WordIndexConcordanceEntry> entries, Boolean matchCase = false, Boolean matchWholeWord = true) #WordIndexConcordanceReportMarks matching paragraphs with hidden XE fields from in-memory concordance entries.
Parameters
- entries System.Collections.Generic.IEnumerable{OfficeIMO.Word.WordIndexConcordanceEntry}
- Concordance entries mapping search text to index text.
- matchCase System.Boolean = false
- Whether matching should be case-sensitive.
- matchWholeWord System.Boolean = true
- Whether matches require non-letter/digit boundaries around the search text.
Returns
A report describing the marks inserted and entries skipped.
public WordIndexConcordanceReport MarkIndexEntriesFromConcordance(WordDocument concordanceDocument, Boolean matchCase = false, Boolean matchWholeWord = true) #WordIndexConcordanceReportReads a Word-style two-column concordance document and marks matching paragraphs with hidden XE fields.
Parameters
- concordanceDocument OfficeIMO.Word.WordDocument
- Concordance document whose first table column contains search text and second column contains index text.
- matchCase System.Boolean = false
- Whether matching should be case-sensitive.
- matchWholeWord System.Boolean = true
- Whether matches require non-letter/digit boundaries around the search text.
Returns
A report describing the marks inserted and entries skipped.
public WordIndexConcordanceReport MarkIndexEntriesFromConcordance(String concordancePath, Boolean matchCase = false, Boolean matchWholeWord = true) #WordIndexConcordanceReportLoads a Word-style two-column concordance document and marks matching paragraphs with hidden XE fields.
Parameters
- concordancePath System.String
- Path to a concordance .docx file.
- matchCase System.Boolean = false
- Whether matching should be case-sensitive.
- matchWholeWord System.Boolean = true
- Whether matches require non-letter/digit boundaries around the search text.
Returns
A report describing the marks inserted and entries skipped.
public Void NormalizeTablesForOnline() #VoidWalks all tables in body and headers/footers and normalizes their grid/widths so online viewers render them consistently.
public IReadOnlyList<Stream> OpenImageStreams() #IReadOnlyList<Stream>Returns streams with data of all embedded images in the document. Images linked externally are skipped.
public Void OpenInApplication(String filePath = null) #VoidOpens the associated document in the operating system's registered application.
Parameters
- filePath System.String = null
public WordTableOfContent RegenerateTableOfContent() #WordTableOfContentRemoves the existing table of contents and creates a new one at the same location.
Returns
The newly created WordTableOfContent.
public Void RejectRevisions(String authorName) #VoidReject all revisions by given author.
Parameters
- authorName System.String
- Author whose revisions should be rejected.
public WordRevisionOperationReport RejectRevisions(WordRevisionFilter filter) #WordRevisionOperationReportRejects revisions that match the provided filter and returns a deterministic operation report.
Parameters
- filter OfficeIMO.Word.WordRevisionFilter
- Filter describing revisions to reject.
public WordRevisionOperationReport RejectRevisionsInParagraph(WordParagraph paragraph, WordRevisionFilter filter = null) #WordRevisionOperationReportRejects revisions inside the specified paragraph.
Parameters
- paragraph OfficeIMO.Word.WordParagraph
- Paragraph that scopes the operation.
- filter OfficeIMO.Word.WordRevisionFilter = null
- Optional additional filter.
public Void RemoveComment(String commentId) #VoidRemoves comment with the specified id.
Parameters
- commentId System.String
- Id of the comment to remove.
public Void RemoveComment(WordComment comment) #VoidRemoves the specified comment from the document.
Parameters
- comment OfficeIMO.Word.WordComment
- Comment instance to remove.
public Void RemoveDocumentVariable(String name) #VoidRemoves the document variable with the specified name if present.
Parameters
- name System.String
- Variable name.
public Void RemoveDocumentVariableAt(Int32 index) #VoidRemoves the document variable at the specified index.
Parameters
- index System.Int32
- Zero-based index of the variable to remove.
Exceptions
ArgumentOutOfRangeExceptionโ Thrown when index is out of range.
public Void RemoveEmbeddedDocument(WordEmbeddedDocument embeddedDocument) #VoidRemoves an embedded document from the document.
Parameters
- embeddedDocument OfficeIMO.Word.WordEmbeddedDocument
- Embedded document to remove.
public Boolean RemoveEmbeddedPayload(String id) #BooleanRemoves an embedded payload and known Word OLE/control markup that references it.
Parameters
- id System.String
public Void RemoveMacro(String name) #VoidRemoves a single macro module from the document.
Parameters
- name System.String
- Module name to remove.
public Void RemoveSection(Int32 index) #VoidRemoves the section at the specified index.
Parameters
- index System.Int32
- Zero based index of the section to remove.
public Void RemoveTableOfContent() #VoidRemoves the current table of contents from the document if one exists.
public Void RemoveWatermark() #VoidRemoves all watermarks from the document including headers.
public Void ReplaceEmbeddedPayload(String id, Byte[] data) #VoidReplaces an embedded payload while preserving its owner relationship.
Parameters
- id System.String
- data System.Byte[]
public Void ReplaceEmbeddedPayload(String id, Stream stream, Nullable<Int64> maxBytes = null) #VoidReplaces an embedded payload from a readable stream.
Parameters
- id System.String
- stream System.IO.Stream
- maxBytes System.Nullable{System.Int64} = null
public Int32 ReplaceTextWithHtmlFragment(String textToFind, String htmlContent, WordAlternativeFormatImportPartType type = Html, StringComparison stringComparison = OrdinalIgnoreCase) #Int32Searches for text in the document and replaces each occurrence with an embedded HTML fragment using AltChunk.
Parameters
- textToFind System.String
- Text to search for.
- htmlContent System.String
- HTML fragment to insert.
- type OfficeIMO.Word.WordAlternativeFormatImportPartType = Html
- Optional format type of the fragment.
- stringComparison System.StringComparison = OrdinalIgnoreCase
- String comparison option for the search.
Returns
The number of replacements performed.
public Void Save(WordSaveOptions options) #VoidSaves to the associated destination with optional save settings.
Parameters
- options OfficeIMO.Word.WordSaveOptions
public Void Save(String filePath) #VoidSave WordDocument to given filePath
Parameters
- filePath System.String
public Void Save(String filePath, WordSaveOptions options) #VoidSave WordDocument to the given file path with optional save policy settings.
Parameters
- filePath System.String
- Destination path.
- options OfficeIMO.Word.WordSaveOptions
- Optional save policy settings.
public Void Save(Stream outputStream) #VoidSave the WordDocument to Stream
Parameters
- outputStream System.IO.Stream
Exceptions
InvalidOperationException
public Void Save(Stream outputStream, WordSaveOptions options) #VoidSave the WordDocument to Stream with optional save behavior.
Parameters
- outputStream System.IO.Stream
- Writable stream that receives the document content. This one-time save does not change the associated destination.
- options OfficeIMO.Word.WordSaveOptions
- Optional save behaviors, including stream physical format selection and signed-document policy.
Exceptions
InvalidOperationException
public Void Save(Stream outputStream, WordFileFormat format, WordSaveOptions options = null) #VoidSaves the document to a stream in the explicitly selected physical format.
Parameters
- outputStream System.IO.Stream
- Writable stream that receives the document content.
- format OfficeIMO.Word.WordFileFormat
- Physical DOCX or DOC format.
- options OfficeIMO.Word.WordSaveOptions = null
- Optional save policy settings.
public IReadOnlyList<OfficeImageExportResult> SaveAsImages(String folderPath, WordImageExportOptions options = null) #IReadOnlyList<OfficeImageExportResult>Saves every selected document page as a PNG file in a folder.
Parameters
- folderPath System.String
- options OfficeIMO.Word.WordImageExportOptions = null
public IReadOnlyList<OfficeImageExportResult> SaveAsImages(String folderPath, OfficeImageExportFormat format, WordImageExportOptions options = null) #IReadOnlyList<OfficeImageExportResult>Saves every selected document page as PNG or SVG in a folder.
Parameters
- folderPath System.String
- format OfficeIMO.Drawing.OfficeImageExportFormat
- options OfficeIMO.Word.WordImageExportOptions = null
public Task<IReadOnlyList<OfficeImageExportResult>> SaveAsImagesAsync(String folderPath, WordImageExportOptions options = null, CancellationToken cancellationToken = null) #Task<IReadOnlyList<OfficeImageExportResult>>Asynchronously saves every selected document page as a PNG file in a folder.
Parameters
- folderPath System.String
- options OfficeIMO.Word.WordImageExportOptions = null
- cancellationToken System.Threading.CancellationToken = null
public Task<IReadOnlyList<OfficeImageExportResult>> SaveAsImagesAsync(String folderPath, OfficeImageExportFormat format, WordImageExportOptions options = null, CancellationToken cancellationToken = null) #Task<IReadOnlyList<OfficeImageExportResult>>Asynchronously saves every selected document page as PNG or SVG in a folder.
Parameters
- folderPath System.String
- format OfficeIMO.Drawing.OfficeImageExportFormat
- options OfficeIMO.Word.WordImageExportOptions = null
- cancellationToken System.Threading.CancellationToken = null
public OfficeImageExportResult SaveAsJpeg(String path, WordImageExportOptions options = null) #OfficeImageExportResultSaves the requested page as JPEG.
Parameters
- path System.String
- options OfficeIMO.Word.WordImageExportOptions = null
public OfficeImageExportResult SaveAsJpeg(Stream stream, WordImageExportOptions options = null) #OfficeImageExportResultWrites the requested page as JPEG.
Parameters
- stream System.IO.Stream
- options OfficeIMO.Word.WordImageExportOptions = null
public Task<OfficeImageExportResult> SaveAsJpegAsync(String path, WordImageExportOptions options = null, CancellationToken cancellationToken = null) #Task<OfficeImageExportResult>Asynchronously saves the requested page as JPEG.
Parameters
- path System.String
- options OfficeIMO.Word.WordImageExportOptions = null
- cancellationToken System.Threading.CancellationToken = null
public Task<OfficeImageExportResult> SaveAsJpegAsync(Stream stream, WordImageExportOptions options = null, CancellationToken cancellationToken = null) #Task<OfficeImageExportResult>Asynchronously writes the requested page as JPEG.
Parameters
- stream System.IO.Stream
- options OfficeIMO.Word.WordImageExportOptions = null
- cancellationToken System.Threading.CancellationToken = null
public OfficeImageExportResult SaveAsPng(String path, WordImageExportOptions options = null) #OfficeImageExportResultSaves the requested document page as a PNG file.
Parameters
- path System.String
- options OfficeIMO.Word.WordImageExportOptions = null
public OfficeImageExportResult SaveAsPng(Stream stream, WordImageExportOptions options = null) #OfficeImageExportResultWrites the requested document page as PNG to a stream.
Parameters
- stream System.IO.Stream
- options OfficeIMO.Word.WordImageExportOptions = null
public Task<OfficeImageExportResult> SaveAsPngAsync(String path, WordImageExportOptions options = null, CancellationToken cancellationToken = null) #Task<OfficeImageExportResult>Asynchronously saves the requested document page as a PNG file.
Parameters
- path System.String
- options OfficeIMO.Word.WordImageExportOptions = null
- cancellationToken System.Threading.CancellationToken = null
public Task<OfficeImageExportResult> SaveAsPngAsync(Stream stream, WordImageExportOptions options = null, CancellationToken cancellationToken = null) #Task<OfficeImageExportResult>Asynchronously writes the requested document page as PNG to a stream.
Parameters
- stream System.IO.Stream
- options OfficeIMO.Word.WordImageExportOptions = null
- cancellationToken System.Threading.CancellationToken = null
public OfficeImageExportResult SaveAsSvg(String path, WordImageExportOptions options = null) #OfficeImageExportResultSaves the requested document page as an SVG file.
Parameters
- path System.String
- options OfficeIMO.Word.WordImageExportOptions = null
public OfficeImageExportResult SaveAsSvg(Stream stream, WordImageExportOptions options = null) #OfficeImageExportResultWrites the requested document page as SVG to a stream.
Parameters
- stream System.IO.Stream
- options OfficeIMO.Word.WordImageExportOptions = null
public Task<OfficeImageExportResult> SaveAsSvgAsync(String path, WordImageExportOptions options = null, CancellationToken cancellationToken = null) #Task<OfficeImageExportResult>Asynchronously saves the requested document page as an SVG file.
Parameters
- path System.String
- options OfficeIMO.Word.WordImageExportOptions = null
- cancellationToken System.Threading.CancellationToken = null
public Task<OfficeImageExportResult> SaveAsSvgAsync(Stream stream, WordImageExportOptions options = null, CancellationToken cancellationToken = null) #Task<OfficeImageExportResult>Asynchronously writes the requested document page as SVG to a stream.
Parameters
- stream System.IO.Stream
- options OfficeIMO.Word.WordImageExportOptions = null
- cancellationToken System.Threading.CancellationToken = null
public OfficeImageExportResult SaveAsTiff(String path, WordImageExportOptions options = null) #OfficeImageExportResultSaves the requested page as TIFF.
Parameters
- path System.String
- options OfficeIMO.Word.WordImageExportOptions = null
public OfficeImageExportResult SaveAsTiff(Stream stream, WordImageExportOptions options = null) #OfficeImageExportResultWrites the requested page as TIFF.
Parameters
- stream System.IO.Stream
- options OfficeIMO.Word.WordImageExportOptions = null
public Task<OfficeImageExportResult> SaveAsTiffAsync(String path, WordImageExportOptions options = null, CancellationToken cancellationToken = null) #Task<OfficeImageExportResult>Asynchronously saves the requested page as TIFF.
Parameters
- path System.String
- options OfficeIMO.Word.WordImageExportOptions = null
- cancellationToken System.Threading.CancellationToken = null
public Task<OfficeImageExportResult> SaveAsTiffAsync(Stream stream, WordImageExportOptions options = null, CancellationToken cancellationToken = null) #Task<OfficeImageExportResult>Asynchronously writes the requested page as TIFF.
Parameters
- stream System.IO.Stream
- options OfficeIMO.Word.WordImageExportOptions = null
- cancellationToken System.Threading.CancellationToken = null
public OfficeImageExportResult SaveAsWebp(String path, WordImageExportOptions options = null) #OfficeImageExportResultSaves the requested page as lossless WebP.
Parameters
- path System.String
- options OfficeIMO.Word.WordImageExportOptions = null
public OfficeImageExportResult SaveAsWebp(Stream stream, WordImageExportOptions options = null) #OfficeImageExportResultWrites the requested page as lossless WebP.
Parameters
- stream System.IO.Stream
- options OfficeIMO.Word.WordImageExportOptions = null
public Task<OfficeImageExportResult> SaveAsWebpAsync(String path, WordImageExportOptions options = null, CancellationToken cancellationToken = null) #Task<OfficeImageExportResult>Asynchronously saves the requested page as lossless WebP.
Parameters
- path System.String
- options OfficeIMO.Word.WordImageExportOptions = null
- cancellationToken System.Threading.CancellationToken = null
public Task<OfficeImageExportResult> SaveAsWebpAsync(Stream stream, WordImageExportOptions options = null, CancellationToken cancellationToken = null) #Task<OfficeImageExportResult>Asynchronously writes the requested page as lossless WebP.
Parameters
- stream System.IO.Stream
- options OfficeIMO.Word.WordImageExportOptions = null
- cancellationToken System.Threading.CancellationToken = null
public Task SaveAsync(CancellationToken cancellationToken = null) #TaskAsynchronously saves the document to where it was open from.
Parameters
- cancellationToken System.Threading.CancellationToken = null
- Cancellation token.
public Task SaveAsync(WordSaveOptions options, CancellationToken cancellationToken = null) #TaskAsynchronously saves to the associated destination with optional save settings.
Parameters
- options OfficeIMO.Word.WordSaveOptions
- cancellationToken System.Threading.CancellationToken = null
public Task SaveAsync(String filePath, CancellationToken cancellationToken = null) #TaskAsynchronously saves the document to the specified file.
Parameters
- filePath System.String
- The path to save the document to.
- cancellationToken System.Threading.CancellationToken = null
- Cancellation token.
public Task SaveAsync(String filePath, WordSaveOptions options, CancellationToken cancellationToken = null) #TaskAsynchronously saves the document to the specified file with optional save policy settings.
Parameters
- filePath System.String
- The path to save the document to.
- options OfficeIMO.Word.WordSaveOptions
- Optional save policy settings.
- cancellationToken System.Threading.CancellationToken = null
- Cancellation token.
public Task SaveAsync(Stream outputStream, CancellationToken cancellationToken = null) #TaskAsynchronously saves the document to a stream as DOCX.
Parameters
- outputStream System.IO.Stream
- Writable destination stream.
- cancellationToken System.Threading.CancellationToken = null
- Cancellation token.
public Task SaveAsync(Stream outputStream, WordSaveOptions options, CancellationToken cancellationToken = null) #TaskAsynchronously saves the document to a stream as DOCX.
Parameters
- outputStream System.IO.Stream
- Writable destination stream.
- options OfficeIMO.Word.WordSaveOptions
- Optional save policy settings.
- cancellationToken System.Threading.CancellationToken = null
- Cancellation token.
public async Task SaveAsync(Stream outputStream, WordFileFormat format, WordSaveOptions options = null, CancellationToken cancellationToken = null) #TaskAsynchronously saves the document to a stream in the selected physical format.
Parameters
- outputStream System.IO.Stream
- Writable destination stream.
- format OfficeIMO.Word.WordFileFormat
- Physical DOCX or DOC format.
- options OfficeIMO.Word.WordSaveOptions = null
- Optional save policy settings.
- cancellationToken System.Threading.CancellationToken = null
- Cancellation token.
public Void SaveCopy(String filePath, WordSaveOptions options = null) #VoidSaves an independent copy without changing this document's associated destination.
Parameters
- filePath System.String
- Destination path.
- options OfficeIMO.Word.WordSaveOptions = null
- Optional save policy settings.
public async Task SaveCopyAsync(String filePath, WordSaveOptions options = null, CancellationToken cancellationToken = null) #TaskAsynchronously saves an independent copy without changing this document's associated destination.
Parameters
- filePath System.String
- options OfficeIMO.Word.WordSaveOptions = null
- cancellationToken System.Threading.CancellationToken = null
public Void SaveEmbeddedPayload(String id, String filePath, Nullable<Int64> maxBytes = null) #VoidSaves an embedded payload by its package-local id.
Parameters
- id System.String
- filePath System.String
- maxBytes System.Nullable{System.Int64} = null
public Void SaveEncrypted(String filePath, String password, WordSaveOptions saveOptions = null) #VoidSaves the document as a password-encrypted Office Open XML package.
Parameters
- filePath System.String
- Destination path.
- password System.String
- Password used to encrypt the document package.
- saveOptions OfficeIMO.Word.WordSaveOptions = null
- Optional save policy settings.
public Void SaveEncrypted(Stream destination, String password) #VoidSaves the document as a password-encrypted Office Open XML package to a stream.
Parameters
- destination System.IO.Stream
- Writable stream receiving the encrypted document.
- password System.String
- Password used to encrypt the document package.
public Void SaveEncrypted(Stream destination, String password, WordSaveOptions saveOptions) #VoidSaves the document as a password-encrypted Office Open XML package to a stream.
Parameters
- destination System.IO.Stream
- Writable stream receiving the encrypted document.
- password System.String
- Password used to encrypt the document package.
- saveOptions OfficeIMO.Word.WordSaveOptions
- Optional save policy settings.
public Void SaveMacros(String filePath) #VoidSaves the VBA project to a file.
Parameters
- filePath System.String
- Destination path.
public Void SaveMacros(String filePath, Int64 maxBytes) #VoidSaves a VBA project while enforcing a maximum byte count.
Parameters
- filePath System.String
- maxBytes System.Int64
public Void SetDocumentVariable(String name, String value) #VoidSets the value of a document variable. Creates it if it does not exist.
Parameters
- name System.String
- Variable name.
- value System.String
- Variable value.
public static WordMacroProjectSigningResult SignMacroProject(String filePath, IOfficeSecurityProvider securityProvider, String certificateThumbprint, WordMacroProjectSigningOptions options = null) #WordMacroProjectSigningResultClears 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 System.String
- Path to a saved DOCM or DOTM package.
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- Cryptographic provider supplied by the optional OfficeIMO.Security package.
- certificateThumbprint System.String
- SHA-1 thumbprint of a certificate with an accessible private key in the configured store.
- options OfficeIMO.Word.WordMacroProjectSigningOptions = null
- Optional certificate-store, OfficeSips, timestamp, validation, and resource policy.
public static WordPackageSigningResult SignPackage(String filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 certificate, WordPackageSigningOptions options = null) #WordPackageSigningResultSigns a saved DOCX package using the cross-platform OPC XML-signature engine and throws when signing cannot be completed and cryptographically verified.
Parameters
- filePath System.String
- Path to the DOCX package to sign.
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- Cryptographic provider supplied by the optional OfficeIMO.Security package.
- certificate System.Security.Cryptography.X509Certificates.X509Certificate2
- Certificate with a private key used for signing.
- options OfficeIMO.Word.WordPackageSigningOptions = null
- Optional package-signing settings.
Returns
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) #WordPackageSigningResultResolves 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 System.String
- Path to the DOCX package to sign.
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- Cryptographic provider supplied by the optional OfficeIMO.Security package.
- certificateThumbprint System.String
- Certificate thumbprint to locate.
- certificateOptions OfficeIMO.Word.WordPackageCertificateStoreOptions = null
- Optional certificate-store lookup settings.
- signingOptions OfficeIMO.Word.WordPackageSigningOptions = null
- Optional package-signing settings.
Returns
A signing result with structural, cryptographic, digest, and certificate-policy validation readback.
public static OfficePackageSigningResult SignPackageSignature(String filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 signingCertificate, OfficePackageSigningOptions options = null) #OfficePackageSigningResultCreates and validates an OPC signature through the shared cross-host engine.
Parameters
- filePath System.String
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- signingCertificate System.Security.Cryptography.X509Certificates.X509Certificate2
- options OfficeIMO.Security.OfficePackageSigningOptions = null
public static OfficeVbaSigningResult SignVbaProject(String filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 signingCertificate, OfficeVbaSigningOptions options = null, IEnumerable<X509Certificate2> certificateChain = null) #OfficeVbaSigningResultCreates and atomically validates legacy, agile, and V3 VBA signatures through the shared owner.
Parameters
- filePath System.String
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- signingCertificate System.Security.Cryptography.X509Certificates.X509Certificate2
- options OfficeIMO.Security.OfficeVbaSigningOptions = null
- certificateChain System.Collections.Generic.IEnumerable{System.Security.Cryptography.X509Certificates.X509Certificate2} = null
public Boolean StyleExists(String styleId) #BooleanDetermines whether a paragraph style with the specified identifier exists in the document.
Parameters
- styleId System.String
- The style identifier to look for.
Returns
true if the style exists; otherwise, false.
public Byte[] ToBytes(WordFileFormat format = Docx, WordSaveOptions options = null) #Byte[]Encodes the document in the selected physical format.
Parameters
- format OfficeIMO.Word.WordFileFormat = Docx
- DOCX or legacy DOC output.
- options OfficeIMO.Word.WordSaveOptions = null
- Optional save policy settings.
public WordDocumentImageExportBuilder ToImage() #WordDocumentImageExportBuilderStarts a fluent image export for this document.
public WordDocumentImageExportBuilder ToImage(WordImageExportOptions options) #WordDocumentImageExportBuilderStarts a fluent image export using a cloned options snapshot.
Parameters
- options OfficeIMO.Word.WordImageExportOptions
public WordDocumentPageImageExportBuilder ToImages() #WordDocumentPageImageExportBuilderStarts a fluent batch image export for document pages.
public WordDocumentPageImageExportBuilder ToImages(WordImageExportOptions options) #WordDocumentPageImageExportBuilderStarts a fluent page batch export using a cloned options snapshot.
Parameters
- options OfficeIMO.Word.WordImageExportOptions
public Byte[] ToJpeg(WordImageExportOptions options = null) #Byte[]Renders the requested page to dependency-free JPEG bytes.
Parameters
- options OfficeIMO.Word.WordImageExportOptions = null
public Byte[] ToPng(WordImageExportOptions options = null) #Byte[]Renders the requested document page to dependency-free PNG bytes.
Parameters
- options OfficeIMO.Word.WordImageExportOptions = null
public MemoryStream ToStream(WordFileFormat format = Docx, WordSaveOptions options = null) #MemoryStreamEncodes the document in a new writable memory stream positioned at the beginning.
Parameters
- format OfficeIMO.Word.WordFileFormat = Docx
- options OfficeIMO.Word.WordSaveOptions = null
public String ToSvg(WordImageExportOptions options = null) #StringRenders the requested document page to dependency-free SVG text.
Parameters
- options OfficeIMO.Word.WordImageExportOptions = null
public Byte[] ToTiff(WordImageExportOptions options = null) #Byte[]Renders the requested page to dependency-free TIFF bytes.
Parameters
- options OfficeIMO.Word.WordImageExportOptions = null
public Byte[] ToWebp(WordImageExportOptions options = null) #Byte[]Renders the requested page to dependency-free lossless WebP bytes.
Parameters
- options OfficeIMO.Word.WordImageExportOptions = null
public Boolean TryGetCompatibilitySourcePayload(out OfficeCompatibilitySourcePayload payload, out String error) #BooleanTries to read an original source retained by a compatibility conversion.
Parameters
- payload OfficeIMO.OfficeCompatibilitySourcePayload@
- error System.String@
public static WordMacroProjectSigningResult TrySignMacroProject(String filePath, IOfficeSecurityProvider securityProvider, String certificateThumbprint, WordMacroProjectSigningOptions options = null) #WordMacroProjectSigningResultAttempts 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 System.String
- Path to a saved DOCM or DOTM package.
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- Cryptographic provider supplied by the optional OfficeIMO.Security package.
- certificateThumbprint System.String
- SHA-1 thumbprint of a certificate with an accessible private key in the configured store.
- options OfficeIMO.Word.WordMacroProjectSigningOptions = null
- Optional certificate-store, OfficeSips, timestamp, validation, and resource policy.
public static WordPackageSigningResult TrySignPackage(String filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 certificate, WordPackageSigningOptions options = null) #WordPackageSigningResultAttempts to sign a saved DOCX package and returns a report instead of throwing for unsupported platforms or signing failures.
Parameters
- filePath System.String
- Path to the DOCX package to sign.
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- Cryptographic provider supplied by the optional OfficeIMO.Security package.
- certificate System.Security.Cryptography.X509Certificates.X509Certificate2
- Certificate with a private key used for signing.
- options OfficeIMO.Word.WordPackageSigningOptions = null
- Optional package-signing settings.
Returns
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) #WordPackageSigningResultAttempts to resolve a signing certificate by thumbprint from the certificate store and sign a saved DOCX package.
Parameters
- filePath System.String
- Path to the DOCX package to sign.
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- Cryptographic provider supplied by the optional OfficeIMO.Security package.
- certificateThumbprint System.String
- Certificate thumbprint to locate.
- certificateOptions OfficeIMO.Word.WordPackageCertificateStoreOptions = null
- Optional certificate-store lookup settings.
- signingOptions OfficeIMO.Word.WordPackageSigningOptions = null
- Optional package-signing settings.
Returns
A signing result with details and validation readback when available.
public static OfficePackageSigningResult TrySignPackageSignature(String filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 signingCertificate, OfficePackageSigningOptions options = null) #OfficePackageSigningResultAttempts shared OPC signature creation without throwing for an ordinary signing failure.
Parameters
- filePath System.String
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- signingCertificate System.Security.Cryptography.X509Certificates.X509Certificate2
- options OfficeIMO.Security.OfficePackageSigningOptions = null
public static OfficeVbaSigningResult TrySignVbaProject(String filePath, IOfficeSecurityProvider securityProvider, X509Certificate2 signingCertificate, OfficeVbaSigningOptions options = null, IEnumerable<X509Certificate2> certificateChain = null) #OfficeVbaSigningResultAttempts shared atomic VBA signing and returns structured failure evidence.
Parameters
- filePath System.String
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- signingCertificate System.Security.Cryptography.X509Certificates.X509Certificate2
- options OfficeIMO.Security.OfficeVbaSigningOptions = null
- certificateChain System.Collections.Generic.IEnumerable{System.Security.Cryptography.X509Certificates.X509Certificate2} = null
public Void UpdateFields() #VoidUpdates 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) #VoidUpdates page and total page number fields, using the supplied options for supported deterministic field refresh.
Parameters
- options OfficeIMO.Word.WordFieldUpdateOptions
- Options controlling deterministic field refresh behavior.
public WordFieldUpdateReport UpdateFieldsAndGetReport() #WordFieldUpdateReportUpdates deterministic field results supported by OfficeIMO and returns structured per-field diagnostics.
Returns
A report describing updated, skipped, unsupported and malformed fields.
public WordFieldUpdateReport UpdateFieldsAndGetReport(WordFieldUpdateOptions options) #WordFieldUpdateReportUpdates deterministic field results supported by OfficeIMO and returns structured per-field diagnostics.
Parameters
- options OfficeIMO.Word.WordFieldUpdateOptions
- Options controlling deterministic field refresh behavior.
Returns
A report describing updated, skipped, unsupported and malformed fields.
public WordContentControlFormValidationResult ValidateContentControlValues(IReadOnlyDictionary<String, Object> values, WordContentControlFormKey keyMode = TagThenAlias, Boolean requireAllControls = true, Boolean allowUnusedValues = false) #WordContentControlFormValidationResultValidates a content-control form map before values are applied to the document.
Parameters
- values System.Collections.Generic.IReadOnlyDictionary{System.String,System.Object}
- Values to validate.
- keyMode OfficeIMO.Word.WordContentControlFormKey = TagThenAlias
- Controls which metadata field is used as the map key.
- requireAllControls System.Boolean = true
- When true, report mapped controls that have no supplied value.
- allowUnusedValues System.Boolean = false
- When false, report supplied values that do not match a mapped control.
Returns
Validation result containing expected keys, supplied keys, and issues.
public List<OfficeOpenXmlValidationError> ValidateDocument(OfficeOpenXmlFileFormatVersion fileFormatVersion = Microsoft365) #List<OfficeOpenXmlValidationError>Validates the document using the specified file format version.
Parameters
- fileFormatVersion OfficeIMO.OfficeOpenXmlFileFormatVersion = Microsoft365
- File format version to validate against.
Returns
List of validation errors.
public static WordMacroProjectSignatureValidationResult ValidateMacroProjectSignature(String filePath, IOfficeSecurityProvider securityProvider, WordMacroProjectSignatureValidationOptions options = null) #WordMacroProjectSignatureValidationResultValidates 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 System.String
- Path to a saved DOCM or DOTM package.
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- Cryptographic provider supplied by the optional OfficeIMO.Security package.
- options OfficeIMO.Word.WordMacroProjectSignatureValidationOptions = null
- Optional native-tool and validation policy.
public static OfficePackageSignatureValidationReport ValidatePackageSignatures(String filePath, IOfficeSecurityProvider securityProvider, OfficePackageSignatureValidationOptions options = null) #OfficePackageSignatureValidationReportValidates a saved DOCX/DOCM package through the shared optional-provider engine.
Parameters
- filePath System.String
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- options OfficeIMO.Security.OfficePackageSignatureValidationOptions = null
public WordSignatureValidationReport ValidateSignatures(IOfficeSecurityProvider securityProvider, WordSignatureValidationOptions options = null) #WordSignatureValidationReportValidates 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
- Cryptographic provider supplied by the caller, typically OfficeSecurityProvider.Default.
- options OfficeIMO.Word.WordSignatureValidationOptions = null
- Trust, revocation, timestamp, and resource policy.
public static OfficeVbaSignatureValidationResult ValidateVbaSignatures(String filePath, IOfficeSecurityProvider securityProvider, OfficeVbaSignatureInspectionOptions options = null) #OfficeVbaSignatureValidationResultValidates VBA signatures through the package-neutral core shared with Excel and PowerPoint.
Parameters
- filePath System.String
- securityProvider OfficeIMO.Security.IOfficeSecurityProvider
- options OfficeIMO.Security.OfficeVbaSignatureInspectionOptions = null
Inherited Methods
public override Boolean Equals(Object obj) #BooleanParameters
- obj Object
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<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<WordHyperLink> HyperLinks { get; } #Collection of all hyperlinks in 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 WordHeaders Header { get; } #Gets the headers of the first section.
public WordHeader HeaderDefaultOrCreate { get; } #Returns the default header of the first section, creating it on demand. Prefer this over Header when you want a non-null result.
public WordHeader HeaderFirstOrCreate { get; } #Returns the first-page header of the first section, creating it on demand by enabling DifferentFirstPage if necessary.
public WordHeader HeaderEvenOrCreate { get; } #Returns the even-page header of the first section, creating it on demand by enabling DifferentOddAndEvenPages if necessary.
public Boolean DifferentFirstPage { get; set; } #Gets or sets a value indicating whether the first page has different headers and footers.
public Boolean DifferentOddAndEvenPages { get; set; } #Gets or sets a value indicating whether odd and even pages use different headers and footers.
public WordFileFormat SourceFormat { get; 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 legacy 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 Boolean HasMacros { get; } #Provides basic support for VBA macro projects.
public IReadOnlyList<WordMacro> Macros { get; } #Gets all macros (module streams) in the document.
public List<WordComment> Comments { get; } #Collection of all comments inserted into the document.
public Boolean HasDocumentVariables { get; } #Determines whether the document contains any document variables.
public Boolean 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; set; } #Path to the file backing this document.
public WordSettings Settings { get; set; } #Provides access to document settings. A missing settings part is created on first use.
public WordApplicationProperties ApplicationProperties { get; set; } #Manages application related properties.
public WordBuiltinDocumentProperties BuiltinDocumentProperties { get; 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> CustomDocumentProperties { get; } #Collection of custom document properties.
public Dictionary<String, String> DocumentVariables { get; } #Collection of document variables accessible via DocVariable fields.
public Dictionary<String, WordBibliographySource> BibliographySources { get; } #Collection of bibliographic sources used in the document.
public WordDocumentStatistics Statistics { get; set; } #Provides basic statistics for the document.
public DocumentPersistenceMode PersistenceMode { get; } #Gets the persistence policy selected when the document was created or loaded.
public Boolean 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> ParagraphsHyperLinks { get; } #Returns paragraphs that include hyperlinks.
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 OfficePageOrientation PageOrientation { get; set; } #Gets or sets the orientation of the pages in the first section.
public WordBorders Borders { get; set; } #Gets or sets the page borders for the first section.
public WordMargins Margins { get; set; } #Gets or sets the margins for the first section.
public WordPageSizes PageSettings { get; set; } #Gets or sets the page size settings for the first section.
public Boolean 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 WordBackground Background { get; set; } #Provides access to the document background settings.
public Boolean 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 an SDK-independent view of the first section's page-numbering configuration.
public WordFootnoteSettings FootnoteSettings { get; } #Gets an SDK-independent view of the first section's footnote configuration.
public WordEndnoteSettings EndnoteSettings { get; } #Gets an SDK-independent view of the first section's endnote configuration.
Extension Methods
public static WordParagraph AddParagraphFromXml(WordDocument document, String xml) #WordParagraphCreates a WordParagraph from the provided XML string and appends it to the document.
Parameters
- document OfficeIMO.Word.WordDocument
- Target document.
- xml System.String
- XML string representing a paragraph.
Returns
The inserted WordParagraph.
public static WordSearchResult Find(WordDocument document, Regex regex) #WordSearchResultSearches the document for text matching the specified regular expression.
Parameters
- document OfficeIMO.Word.WordDocument
- Document to search.
- regex System.Text.RegularExpressions.Regex
- Regular expression used for searching.
Returns
A WordSearchResult containing all matches.