Skip to main content Skip to footer

What's New in GrapeCity Documents for Word v3 (Word .NET API)

GrapeCity Documents for Word (GcWord), is a Word API offering a complete solution to programmatically create, modify, and save Word documents in .NET Core applications without installing MS Word on your system. The object model is based on Microsoft Office API, Word Javascript API, and OpenXML SDK to create complete MS Word-like documents.

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.

Let's dive in...

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

What do you think about above features in GcWord? Please leave a comment below.

Shilpa Sharma - Product Manager

Shilpa Sharma

Product Manager
comments powered by Disqus