[]
        
(Showing Draft Content)

GrapeCity.Documents.Word.GcWordDocument

Class GcWordDocument

Namespace
GrapeCity.Documents.Word
Assembly
GcDocs.Word.dll

Represents a Word document.

Contains one or more sections, content controls, and body representing the content of the document.

public class GcWordDocument : DocumentBase
Inheritance
object
GcWordDocument
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()

Constructors

GcWordDocument(string)

Creates a new instance of the GcWordDocument class, optionally specifying a license key.

public GcWordDocument(string licenseKey = null)

Parameters

licenseKey string

The license key to use. If null, and SetLicenseKey(string) has been called, the key set with that method is used.

Properties

Body

Gets the main body of the document.

public Body Body { get; }

Property Value

Body

CustomXmlParts

Gets the collection of CustomXmlPart objects.

public CustomXmlPartCollection CustomXmlParts { get; }

Property Value

CustomXmlPartCollection

Remarks

There are two default parts that are always created with a document. These are doc properties, and app properties.

DataTemplate

Gets the DataTemplate object that provides properties and methods used to manage template data sources and process data templates.

public DataTemplate DataTemplate { get; }

Property Value

DataTemplate

GlossaryDocument

Gets a supplementary document storage which stores the definition and content for content that shall be carried with the document for future insertion and/or use, but which shall not be visible within the contents of the main document story.

public GlossaryDocument GlossaryDocument { get; }

Property Value

GlossaryDocument

HideLinkedCharacterStyles

Gets or sets whether to hide linked character styles.

public bool HideLinkedCharacterStyles { get; set; }

Property Value

bool

MalformedUriRewriter

Gets or sets the malformed URI rewriter that can be used to implement a custom strategy for rewriting malformed URIs.

By default this property is null (i.e. no rewriting takes place).

Set this to an instance of the DefaultMalformedUriRewriter class to use the default rewriting strategy, or use a custom IMalformedUriRewriter implementation.

public IMalformedUriRewriter MalformedUriRewriter { get; set; }

Property Value

IMalformedUriRewriter

Theme

Gets the theme that holds all formatting options available to a document through a theme.

public Theme Theme { get; }

Property Value

Theme

Methods

GetPropertyValueSource<T>(Expression<Func<T>>)

Gets the source of a formatting property.

This method finds and returns the object in the inheritance chain that determines the actual current value of the specified formatting property.

For example, to find the object that determines the font size of the first run in the document body:

var o = GetPropertyValueSource(() => document.Body.Runs.First.Font.Size);

In this example, if the Heading 1 style was applied to the paragraph containing that run, this method would return that style.

public static object GetPropertyValueSource<T>(Expression<Func<T>> property)

Parameters

property System.Linq.Expressions.Expression<TDelegate><Func<T>>

An expression that returns a property derived from the FormattingBag class.

Returns

object

If the property is inheritable, the object in the inheritance chain that explicitly specifies the property value, or null if the property value is not specified and the property has the default value.

If the property is not inheritable, the property owner is returned.

Type Parameters

T

Load(Stream)

Loads a System.IO.Stream that contains OpenXml formatted data into the document.

public void Load(Stream stream)

Parameters

stream System.IO.Stream

The OpenXml formatted data System.IO.Stream to load.

Load(string)

Loads an OpenXml formatted file into the document.

public void Load(string fileName)

Parameters

fileName string

The OpenXML formatted file to load.

MergeDocuments(FormattingCopyStrategy, params GcWordDocument[])

Merges several source documents into a single new GcWordDocument.

public static GcWordDocument MergeDocuments(FormattingCopyStrategy copyStrategy, params GcWordDocument[] mergedDocuments)

Parameters

copyStrategy FormattingCopyStrategy

Specifies how formatting of the source documents is handled.

mergedDocuments GcWordDocument[]

The source documents to merge.

Returns

GcWordDocument

The newly created GcWordDocument consisting of the merged Body ranges of the source documents.

MergeDocuments(params GcWordDocument[])

Merges several source documents into a single new GcWordDocument, using Copy to preserve formatting of the source documents.

public static GcWordDocument MergeDocuments(params GcWordDocument[] mergedDocuments)

Parameters

mergedDocuments GcWordDocument[]

The source documents to merge.

Returns

GcWordDocument

The newly created GcWordDocument consisting of the merged Body ranges of the source documents.

MergeDocuments(params (GcWordDocument, FormattingCopyStrategy)[])

Merges several source documents into a single new GcWordDocument.

public static GcWordDocument MergeDocuments(params (GcWordDocument, FormattingCopyStrategy)[] mergedDocuments)

Parameters

mergedDocuments (GcWordDocument, FormattingCopyStrategy)[]

An array of pairs of source documents and corresponding formatting copy strategies.

Returns

GcWordDocument

The newly created GcWordDocument consisting of the merged Body ranges of the source documents.

Save(Stream, DocumentType)

Saves the document to a System.IO.Stream.

public void Save(Stream stream, DocumentType type = DocumentType.Document)

Parameters

stream System.IO.Stream

The System.IO.Stream where to save document.

type DocumentType

The document type to save to.

Save(string, DocumentType)

Saves the document to an OpenXml formatted file.

public void Save(string fileName, DocumentType type = DocumentType.Document)

Parameters

fileName string

The file path to save to.

type DocumentType

The document type to save to.

SetLicenseKey(string)

Sets the license key.

public static void SetLicenseKey(string key)

Parameters

key string

The license key to set.

SplitDocument(FormattingCopyStrategy, params RangeBase[])

Splits the current document into several documents based on specified ranges and a common formatting copy strategy.

public IEnumerable<GcWordDocument> SplitDocument(FormattingCopyStrategy copyStrategy, params RangeBase[] splitRanges)

Parameters

copyStrategy FormattingCopyStrategy

The formatting copy strategy to use.

splitRanges RangeBase[]

An array of ranges in the current document.

Returns

System.Collections.Generic.IEnumerable<T><GcWordDocument>

A collection of documents created according to the specified splitRanges.

SplitDocument(params RangeBase[])

Splits the current document into several documents based on specified ranges, using Copy to preserve formatting of the source document.

public IEnumerable<GcWordDocument> SplitDocument(params RangeBase[] splitRanges)

Parameters

splitRanges RangeBase[]

An array of ranges in the current document.

Returns

System.Collections.Generic.IEnumerable<T><GcWordDocument>

A collection of documents created according to the specified splitRanges.

SplitDocument(params (RangeBase splitRange, FormattingCopyStrategy copyStrategy)[])

Splits the current document into several documents based on specified ranges and formatting copy strategies.

public IEnumerable<GcWordDocument> SplitDocument(params (RangeBase splitRange, FormattingCopyStrategy copyStrategy)[] splitRanges)

Parameters

splitRanges (RangeBase splitRange, FormattingCopyStrategy copyStrategy)[]

An array of pairs of ranges in the current document, and corresponding formatting copy strategies.

Returns

System.Collections.Generic.IEnumerable<T><GcWordDocument>

A collection of documents created according to the specified splitRanges.