A glossary document is a supplementary storage which stores the content, such as AutoText/Buildingblock entries that you do not want to appear in the document, but want to keep it as the part of document for future insertion, if needed. DsWord provides the capability of maintaining a GlossaryDocument for a Word document to store the BuildingBlocks content. It is represented using the GlossaryDocument class.
GlossaryDocument class maintains the collection of building blocks using the BuildingBlockCollection class. The BuildingBlockCollection class provides Add and Remove method to add and remove the blocks from the glossary document respectively.
Building blocks is an essential feature of word which allows you to insert blocks of information in the document. These blocks of information can be reusable chunks of content or pre-designed and pre-formatted blocks of text and formatting. DsWord allows you to create, modify and delete building blocks using the BuildingBlock class.
To create and add building blocks in a glossary document:
C# |
Copy Code |
---|---|
GcWordDocument doc = new GcWordDocument(); //Adds a building block that contains text BuildingBlock bb1 = doc.GlossaryDocument.BuildingBlocks.Add("Mission_Statement", "CompanyInfo", BuildingBlockGallery.AutoText, BuildingBlockInsertOptions.Content, BuildingBlockType.None); Style paraStyle = bb1.Body.Document.Styles.Add("paraStyle", StyleType.Paragraph); paraStyle.Font.Bold = true; bb1.Body.Paragraphs.Add("To serve our customers by helping them to achieve their goals", paraStyle); //Save the document (Note:Building blocks can be saved in dotx and docx, but in the docx format, MS Word UI won't show them) doc.Save("CustomBuildingBlocks.dotx", DocumentType.Template); |
To remove building block from glossary document:
C# |
Copy Code |
---|---|
GcWordDocument doc = new GcWordDocument(); doc.Load("CustomBuildingBlocks.dotx"); doc.GlossaryDocument.BuildingBlocks.Remove(doc.GlossaryDocument.BuildingBlocks.First); |