GcWord v3.1

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

!!! partial: section_inpage_download headline: Try GcWord free for 30 days subhead: Download the latest version of GrapeCity Documents for Word download-form:

  • watson-download-product: '59932' watson-redirect-to: /en/download/documents-word/thankyou
    !!!

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

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