DocumentFormatInstance Class
Represents a specific format of a document. Implement this class to add your own document types.
Inheritance Hierarchy
SystemObject
  GroupDocs.Redaction.IntegrationDocumentFormatInstance

Namespace: GroupDocs.Redaction.Integration
Assembly: GroupDocs.Redaction (in GroupDocs.Redaction.dll) Version: 19.9
Syntax
public abstract class DocumentFormatInstance

The DocumentFormatInstance type exposes the following members.

Constructors
  NameDescription
Protected methodDocumentFormatInstance
Initializes a new instance of the DocumentFormatInstance class
Properties
  NameDescription
Public propertyPassword
Gets or sets a password for password protected documents.
Methods
  NameDescription
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the type of the current instance.
(Inherited from Object.)
Public methodCode exampleInitialize
Performs initialization of the instance of document format handler.
Public methodLoad
Loads the document from a stream.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodPerformBinaryCheck
Checks if the given stream contains a document, supported by this format instance.
Public methodSave
Saves the document to a stream.
Protected methodSetAccessGranted
Sets a validation status, if the document requires password.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Examples
The following example demonstrates how to create an empty stub for a custom format handler.
C#
public class DummyDocument : DocumentFormatInstance
{     
    public override void Load(Stream output)
    {
        // load file content
    }

    public override void Save(Stream output)
    {
        // save changes to file;
    }
}

The following example demonstrates how to use the initialization data.

C#
public class MyCustomHandler : DocumentFormatInstance
{
    private string MyProperty { get; set; }

    // Other custom code 
    ...

    public override void Initialize(DocumentFormatConfiguration config)
    {
        base.Initialize(config);
        if (config.InitializationData.ContainsKey("MyProperty"))
        {
            MyProperty = config.InitializationData["MyProperty"];
        }
    }
}

// Plugging custom format into GroupDocs.Redaction
var mySettings = new DocumentFormatConfiguration();
mySettings.ExtensionFilter = ".foo";
mySettings.DocumentType = typeof(MyCustomHandler);
mySettings.InitializationData.Add("MyProperty", "bar");
var configuration = RedactorConfiguration.GetInstance();
configuration.AvailableFormats.Add(mySettings);
See Also