GrapeCity Documents for Word v3.2 - August 13, 2020

Shapes Support

GrapeCity Documents

Add and edit shapes. Choose from a wide range of geometric shapes, shape presets, and theme-based shape styles. Change the shape of a company logo, or remove the borders of shapes in a document from multiple places in the document. Modify the shapes for size, color, or fill type across several Word documents.

Many Word documents use shapes to emphasise ideas or highlight important points. The Word API supports the object model of the shapes supported in MS Word. That makes it possible to load and edit shapes and save Word documents without losing shapes or shape properties.

GrapeCity Documents for Word (GcWord) adds new API to the existing shapes support to create and manipulate shapes in Word documents.

Use the following features while working with shapes:

Add Shapes Supported in MS Word

You can now add any shape supported in MS Word to a Word document through GcWord API. This support enhances loading of any Word document having shapes into GcWord object model, modifying shape properties and saving back. Following Shape types are supported:

Geometric Shapes (188 types supported)

GrapeCity Documents

Add a Shape Type with a GeometryType enum and set shape properties.

//Draw an yellow arc.
            var doc = new GcWordDocument();
            //Picture shape we creates in the Run element.      
            var run = doc.Body.Paragraphs.Add().GetRange().Runs.Add();
            var shape = run.GetRange().Shapes.Add(200,300,GeometryType.Arc);
            
            shape.Line.Fill.Type = FillType.Solid;
            shape.Line.Fill.SolidFill.ThemeColor = ThemeColorId.Accent4;
            

Visit Help | Demo

Group Shapes

GroupShape class in GcWord represents a group shape element in the body content. It helps set unified properties for child shapes. Viewed as a "shape container."

GrapeCity Documents

Visit Help | Demo

Ink Shapes

Ink shapes help users draw lines or curves in a document. Current support of Ink shapes In GcWord loads a Word file having Ink shapes and modifies it automatically through the Ink class. Providing outer Xml defines the Ink shape, and makes creating new ink shapes possible.

GrapeCity Documents

Visit Help | Demo

Canvas Shapes

GrapeCity Documents

When a Word document consists of several shapes, adding a drawing canvas helps arrange the shapes in a container. Add a canvas shape with the Add and Insert methods of the CanvasShapeCollection class.

Visit Help

Picture

GrapeCity Documents

Create a picture shape using the Picture class in a Word document.

Add a picture to a Word document. Set the outline width, fill type, and location properties. Load Word documents with pictures, modify and save them. This allows modifications to several documents containing the same picture image.

Visit Help

Fill Format and Line Format

GrapeCity Documents

Fill and line formats are essential to make illustrations complete. These properties help distinguish between various shapes.

Use the FillFormat class to set various types of fill formats like PatternFill, SolidFill, ImageFill, and GradientFill. The FillType enum defines the active fill type.

Similarly, the LineFormat class contains various properties that define the appearance of shape lines. FillFormat defines fill properties.

Note: If FillFormat or LineFormat are not defined on the shape, their value is taken from the ShapeStyle class (if present in the document).

Read more about the ShapeStyle class here.

Help | Demo

Themed Shape Styles

GrapeCity Documents

GcWord supports 42 t**hemed styles. Add these to any shape in a word document. Use the ApplyThemedStyle** method overloads to add themed styles to a shape. These themes are the easiest options for applying a theme to a shape with desired properties.

Help | Demo

Shape Presets

GrapeCity Documents

Sometimes presets are used more often than themed styles. Some of these styles are perfect for adding a transparent or semi-transparent shape with one click. GcWord supports about 29 s**hape p**reset types through the ApplyPreset method overloads.

Visit Help | Demo

GcWord v3.1 - March 26, 2020

Find and Replace Text

GcWord adds the support of Find and Replace text using the new RangeBaseFindReplaceExtensions class. You can not only search simple text but also find and replace pattern-based text like regex patterns or unique tokens (and even search for text-based on specific formatting).

With batch processing of hundreds of Word documents, you can use the find and replace methods as a quick way to find/replace a particular portion of text/patterns/formatted text over those documents.

For example, if you have hundreds of Word documents that include a company email ID, and your company changes it to another address, you can use the GcWord API to load the Word documents. Find the email ID by pattern, and replace the email IDs in each document in only a few seconds!

In the example below, an organization sending a procurement letter has designed a Word template with placeholders of data fields. They want the Word API to recognize the placeholders, and replace it with the right pair of data.

// Placeholders and sample data:
            (string placeholder, string data)[] placeholderData =
                        {
                            ("__%c_name%__", "Nancy Davolio"),
                            ("__%c_title%__", "Chief Procurement Officer"),
                            ("__%c_phone%__", "555-543-5432"),
                            ("__%c_url%__", "www.acmeinc.com"),
                            ("__%c_address%__", "5432 Street West, Townsvilla, State 54321"),
                            ("__%to_name%__", "Mark"),
                            ("__%dlr_name%__", "AMA Ltd"),
                            ("__%order_no%__", "8393"),
                        };
            
            // Load the document:
            var doc = new GcWordDocument();
            doc.Load(Path.Combine("Resources", "WordDocs", "ProcurementLetterTpl.docx"));
            
            foreach ((string placeholder, string data) pair in placeholderData)
            FindReplace.Replace(doc.Body, pair.placeholder, pair.data);
            

Visit Help | Demo

Support for Textboxes

You can now add text boxes to your Word documents using the new Shapes and TextFrame objects. Using this feature, you can apply various formatting properties to the text. The TextFrame object helps you render text on a shape. If you have additional text that does not fit in the TextFrame, you can make use of LinkedTextFrame to flow the main TextFrame content into it. With GcWord, you can add, modify, or delete text boxes from Word Documents.

You can add unique text anywhere in your document to emphasize a key point or apply unique properties, like TextOrientation (rotating the text), TextWrap, WordWrap, and WrapFormat, on the text to get the user's attention. Add labels, tags, or small quotes as text boxes to make your text look standout.

(Note: In v3.1, exporting Textboxes to PDF is not supported).

Visit Help | Demo

GCWord v3 - October 30, 2019

With v3 release, GcWord adds more features from the Microsoft Word OM features. The special highlight of v3 is the support for merging/splitting documents and document protection.

Copy and Move Document Content

It can be challenging to combine content from multiple Word documents, each with different formatting (and merged content) to fit the destination formatting.

At the same time, there may be a very large Word document from which it may be difficult to find relevant information. The document may need to be split into documents, with relevant content from specific parts of the Word document.

Help - Copy or Move Document Content | Help - Split or Merge Document | Demo - Copy/Move Range | Demo - Split Document | Demo - Merge Documents

Add Document Protection to Word Documents

If you would like only certain people to open and/or edit a Word document with sensitive information, you can now apply Document protection properties in the Word documents. The properties will help keep the information private or secure. These properties will help control types of modifications applied to the documents. You can also specify if the document draft is the final version for the users.

Whats New in GrapeCity Documents for Word v3

The GcWord API adds Microsoft Word OM features w.r.t Document Protection and provides several options with the DocumentProtection, EditProtection classes for securing the Word document.

Features Supported in v3:

  • Add editing restrictions to the document to prevent edits by mistake
  • Add password and password properties to the document to encrypt the Word document, so that no one can access it without the right password
  • Mark document as Final to let users infer that the document hasn't changed since last saved
  • Apply read-only mode to the document
  • Apply document edit mode to limit the content that can be edited, the modes are:
    • No Protection
    • AllowOnlyReading
    • AllowOnlyComments
    • AllowOnlyRevisions
    • AllowOnlyFormFields
  • Specify if document's style can be modified or not while editing the document
  • Check whether restrictions were applied and active

More information and how to set document protection properties here.

Add Editable Ranges and Set Editor Permissions to Modify Document Content

In addition to Document protection, you can allow certain portions of text, to be editable by a designated set of people. With GcWord, you can add the range as Editable range, and set the Group editor for that range using the EditableRange and GroupEditor enum.

GcWordDocument doc = new GcWordDocument();
            
            //add new paragraph
            var para = doc.Body.Paragraphs.Add("Editable paragraph");
            //add new EditableRange for this paragraph
            para.getRange().EditableRanges.Add(new GroupEditor(EditorGroup.Everyone));
            
            //add new paragraph
            doc.Body.Paragraphs.Add("New paragraph");
            
            //set document region protection mode
            doc.Settings.DocumentProtection.EditProtection.EditMode = EditProtectionMode.AllowOnlyReading;
            //enforce document protection
            doc.Settings.DocumentProtection.EditProtection.isActive = true;
            
            //now, first paragraph can be editable by everyone.
            //rest of the document is ReadOnly
            doc.Save("EditableRange.docx");
            

In the document above, the first paragraph is set as an Editable range and editing permissions are provided to everyone. These settings do not apply to the 'New paragraph' so the next paragraph would be read-only and not editable.

Documentation Help

Detect Source of Formatting Properties

In a Word document, formatting of a fragment can be determined in different things:

  • Default document style
  • Parent content formatting (paragraph that also includes font, for a run)
  • Direct formatting (user selecting a word and applying font/color)

While programming with Word documents, it is useful to find out where a font comes from a run: from default style, paragraph style, or direct formatting.

GcWord adds the GcWordDocument.GetPropertyValueSource method to get the source of formatting properties. This feature is for advanced users, who want to programmatically determine the formatting of the Word objects uses in the Word document.

This is useful when a user wants to make sure all documents within the organization use pre-defined styles and not direct formatting. In that case, the programmer might want to find out which objects have what formatting properties set in the document and instead set pre-defined styles on the objects to make all documents follow a standard style.

More details here:

Help | Demo