Document Manipulation

The Word API Document Manipulation allows the following edits to be made on files created in Microsoft Word.
This feature is only available in the .NET interface.

For API specification, see the document generated by Doxygen.

Retrieving and adding paragraphs

The Word API allows you to get and add paragraphs in the areas shown in the figure below.
Footnotes, endnotes, and comments can be added for paragraphs obtained or added in the body area.
Document editable areas

Below is a sample code that uses the Word API to create a file identical to the one shown above from a blank Microsoft Word file.

var inputFilePath = @""; var outputFilePath = @""; using var ahWord = new AHWordprocessingDocument(inputFilePath); var ahDocument = ahWord.AHDocument; var ahParagraph = ahDocument.GetParagraph(1); ahParagraph.AppendText("footnote"); var ahFootnote = ahParagraph.AddFootnote("Footnote"); ahParagraph = ahDocument.AddParagraph(); ahParagraph.AppendText("comment"); var ahComment = ahParagraph.AddComment("Comment", "John Smith", "comment"); ahParagraph = ahDocument.InsertParagraph(2); ahParagraph.AppendText("endnote"); var ahEndnote = ahParagraph.AddEndnote("Endnote"); var ahSection = ahDocument.GetAHSection(1); var ahHeader = ahSection.AddHeader(AHHeaderFooterType.OddPages); ahParagraph = ahHeader.AddParagraph(); ahParagraph.AppendText("header"); var ahFooter = ahSection.AddFooter(AHHeaderFooterType.OddPages); ahParagraph = ahFooter.AddParagraph(); ahParagraph.AppendText("footer"); ahWord.Save(outputFilePath);
Document Manipulation Result

Editting property information

The Word API allows you to edit property information for Microsoft Word files.
Below is a sample code to add property information to a blank Microsoft Word file and an image of the resulting file.

var inputFilePath = @""; var outputFilePath = @""; using var ahWord = new AHWordprocessingDocument(inputFilePath); var ahCore = ahWord.AHCore; ahCore.SetCreators("Anderson", "Baker"); ahCore.SetTitle("V0.5 additional feature"); ahCore.SetDescription("Editting property information"); ahCore.SetLastModifiedBy("Carter"); ahCore.SetKeyWords("core", "app", "property"); var ahApp = ahWord.AHApp; ahApp.SetCompany("Antenna House"); ahApp.SetManagers("Daniel"); ahWord.Save(outputFilePath);
Document Manipulation Add Property Informations