ComHelper Class
Contains methods that can be useful for users which are calling GemBox.Document component using COM interop.
- Inheritance:
- System.ObjectComHelper
Constructors
ComHelper()
Initializes a new instance of the ComHelper class.
Methods
ComSetLicense(String)
Call this method from your application to set GemBox.Document serial key.
Parameters
serialKey
- System.String
The serial key.
Remarks
You should call this method before using any other class from GemBox.Document assembly.
Key can only be set once (if you try another key, exception will be thrown).
The best place to call this method is from static constructor of your application's main class.
Valid serial key has multiple groups of alphanumeric characters, separated with dashes.
To use the assembly in free limited mode use FREE-LIMITED-KEY as serialKey
.
For more information about GemBox.Document evaluation and licensing, see evaluation and licensing.
GetChildElements(Object, Boolean, Int32)
Gets the parent's child elements filtered by ElementType.
public ArrayList GetChildElements(object parent, bool recursively, int filterElement)
Public Function GetChildElements(parent As Object, recursively As Boolean, filterElement As Integer) As ArrayList
Parameters
parent
- System.Object
The parent element.
recursively
- System.Boolean
true to get all descendants elements; otherwise false to get just child elements.
filterElement
- System.Int32
The ElementType to filter by.
Returns
- System.Collections.ArrayList
Array of child elements filtered by ElementType.
GetElementCollectionCount(Object)
Gets the number of elements contained in the ElementCollection.
public int GetElementCollectionCount(object elements)
Public Function GetElementCollectionCount(elements As Object) As Integer
Parameters
elements
- System.Object
The ElementCollection instance.
Returns
- System.Int32
The number of elements contained in the ElementCollection.
GetElementCollectionItem(Object, Int32)
Gets the Element from ElementCollection at the specified index.
public Element GetElementCollectionItem(object elements, int index)
Public Function GetElementCollectionItem(elements As Object, index As Integer) As Element
Parameters
elements
- System.Object
The ElementCollection instance.
index
- System.Int32
The zero-based index of the Element to get.
Returns
Load(String)
Loads a document from a file with the specified path.
Parameters
path
- System.String
The path from which to load a document.
Returns
A loaded document.
Remarks
File extension that is extracted from the path
is used to create the appropriate LoadOptions derived class instance that is then passed to the Load(String, LoadOptions) method.
Following file extensions are supported:
- Microsoft Word: .docx, .docm, .dotm, .dotx
- Microsoft Word 97-2003: .doc, .dot
- OpenDocument Text: .odt
- Portable Document Format: .pdf
- HyperText Markup Language: .htm, .html, .mht, .mhtml
- Extensible Markup Language (Flat OPC and WordML): .xml
- Rich Text Format: .rtf
- Plain Text: .txt
Exceptions
- System.InvalidOperationException
If file extension is not specified or not supported. If file extension is not recognized, use Load(String, LoadOptions) method overload instead.
LoadWithOptions(String, Object)
Loads a document from a file with the specified path.
public DocumentModel LoadWithOptions(string path, object options)
Public Function LoadWithOptions(path As String, options As Object) As DocumentModel
Parameters
path
- System.String
The path from which to load a document.
options
- System.Object
The loading options which can be used to define settings for load operation.
Returns
A loaded document.
RemoveElementCollectionItem(Object, Int32)
Removes the Element at the specified index.
public void RemoveElementCollectionItem(object elements, int index)
Public Sub RemoveElementCollectionItem(elements As Object, index As Integer)
Parameters
elements
- System.Object
The ElementCollection instance.
index
- System.Int32
The zero-based index of the Element to remove.
SaveWithOptions(Object, String, Object)
Saves the document to a file with the specified path.
public void SaveWithOptions(object document, string path, object options)
Public Sub SaveWithOptions(document As Object, path As String, options As Object)
Parameters
document
- System.Object
The DocumentModel instance which to save.
path
- System.String
The path to which to save the document.
options
- System.Object
The saving options which can be used to define settings for save operation.