What's New in Documents for Word v2
GCWord v2 Service Pack 2
Support for Content Controls
Creating templates, forms, or documents are some common scenarios executed in MS Word; for example, arranging a school parent/teacher meeting using dynamic forms. The form should be a template that includes the school logo and school name by default along with the form field labels. The school has thousands of active students and would like to generate a pre-filled field bound to a database in order to send it online.
With the support of Content Controls, forms can now be designed using GcWord. You can add many types of content controls with respective properties to design forms and templates.
New Types of Content Controls
- RichText
- Text
- Picture
- ComboBox
- DropdownList
- BuildingBlockGallery
- BuildingBlock
- Date
- Group
- CheckBox
- Equation
- Bibliography
- Citation
- RepeatingSection
- RepeatingSectionItem
- ExternalContentEntityPicker
Support Custom XML Parts and XML Mapping
Custom XML parts are used in Word documents to store XML data. Content controls can be bound with these XML parts to generate forms and template documents. A good part of this binding occurs when a user edits the text in the UI of a Word document and the corresponding XML element is automatically updated. Similarly, if element values in the custom XML parts are changed, the bound content controls to the XML elements display the new data.
The binding of content control with XML parts can be used in many scenarios. For example, an online store wants to send annual greetings to customers and needs to add a customized note, stating the yearly bonus added to the account.
The data is in the form of an XML document that contains XML data with the customer's name and other details. This data needs to be mapped to the content controls in order to generate multiple greeting letters. In the document above, CustomerName from the XML file is mapped to PlainText content control.
In this release, we added the capability of binding content controls to these XMP parts using CustomXMLPart class in GcWord. You can add, load, and modify custom XML parts and save the document with custom XML parts as .docx files.
Binding in this way is convenient because if a user edits the text in the UI of a Word document, the corresponding XML element is automatically updated. Similarly, if element values in the custom XML parts are changed, the content controls that are bound to the XML elements display the new data. To bind content controls with XML parts, GcWord also provides the XMLMapping class. You can map the content control with the XML node, or map any built-in property value with a content control.
GcWordDocument doc = new GcWordDocument();
// create custom xml element to map
const string ns = "http://cusomxml/";
XmlDocument xml = new XmlDocument();
xml.AppendChild(xml.CreateXmlDeclaration("1.0", "utf-8", null));
XmlNode root = xml.AppendChild(xml.CreateElement("root", ns));
XmlNode child = root.AppendChild(xml.CreateElement("child", ns));
child.InnerText = "test value";
// add the xml document to a new custom xml part
doc.CustomXmlParts.Add(xml);
// map a new content control to the xml element
ContentControl cc = doc.Body.ContentControls.Add(ContentControlType.Text, false);
// gets the content control mapped value
string value = cc.XmlMapping.SetMapping(child);
// change the mapped value in the xml document and the content control
cc.XmlMapping.TrySetValue("new test value");
// set a built-in property value
doc.Settings.BuiltinProperties.Author = "me";
doc.Body.Paragraphs.Add();
// add a new content control for the built-in property
ContentControl ccp = doc.Body.ContentControls.Add(ContentControlType.Text, false);
// map the built-in property value with the content control
// now when a user user changes the content control value the built-in property will be changed automatically
string author = ccp.XmlMapping.SetMapping(() => doc.Settings.BuiltinProperties.Author);
doc.Save("xml-mapping.docx");
Support for Adding Glossary Documents
You may have certain content that you do not want to appear in the Word document, but still want to keep as part of the document for future insertion as per user action. A Glossary document acts as supplementary document storage that stores the definition and content for those instances.
For example, if you have a real estate contract document where you would like to keep certain optional clauses, you would want to add them as an optional clause and choose from the footer dropdown.
GcWord adds the GlossaryDocument and BuildingBlock classes to be able to add this type of kind of content to Word documents. Since this is in MS Word, there are several pre-defined blocks of text and formatting (known as Building Blocks). The Building Block galleries include pre-formatted Headers, Footers, Page Numbers, Text Boxes, Cover Pages, Watermarks, Quick Tables, Tables of Contents, Bibliographies, and Equations. The BuildingBlock class will help in adding content, (like a GlossaryDocument) to any Building Block Gallery type.
GCWord v2 Service Pack 1
Documents for Word (GcWord) offers a rich and comprehensive object model that is simple to use and is based on Microsoft Office API, Word JavaScript API, and OpenXML SDK. With the new v2 Service Pack 1, we add more Microsoft Word OM features to the feature set, additional language support, and more.
Support for exporting RTL text, vertical text, and East Asian languages to PDF
GcWord API adds support for RightToLeft, vertical text, and East Asian Languages to render documents in multiple languages in DOCX files and export them to PDF. While creating Word documents, you can control:
- First and last character settings
- Line breaking rules
- Kerning
- Character spacing
Try demos: Multiple languages, Tate Chu Yoko, Vertical Text | Documentation
Set view options on Word files
This feature supports how a document is displayed when it's opened in an application. It controls the view type and zoom type of the document when it opens, along with other properties.
Set compatibility options
Adding CompatibilityOptions to the Word files ensures that the Word documents created in older versions retain their properties when opened in newer versions. The addition of CompatibilityOptions class gives users control over 70+ compatibility features of Word files.
Control hyphenation in text
With the GcWord HyphenationOptions class, you can control hyphenation with various options to either automatically hyphenate the document that you create, or set an option to use the hyphenation tool to manually hyphenate your document.
Improve speed when creating new document
We are continuously monitoring the performance of GcWord with every release and have been working on improving the experience of generating word documents. Now you can generate multiple instances of GcWordDocument in just a few seconds as creating a GcWordDocument is 4 times faster than before. Check out the demo sample below.
Support for theme colors
You can now set theme colors and modify existing themes per your company's brand. You can set color schemes that define the colors for background and text in your documents.
Format text as superscript or subscript and export to PDF
You can apply superscript and subscript settings to text in chemical compounds, formulas, mathematical expressions, etc., and GcWord now supports exporting superscript/subscript text to PDF.
For a list of bug fixes, visit the Release Notes.
Updates
- Support for Content Controls
- Support Custom XML Parts and XML Mapping
- Support for Adding Glossary Documents
- Support for exporting RTL text, vertical text, and East Asian languages to PDF
- Set view options on Word files
- Set compatibility options
- Control hyphenation in text
- Improve speed when creating a new document
- Support for theme colors
- Format text as superscript or subscript and export to PDF
Related Links