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: 20.2
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 (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodCode exampleInitialize
Performs initialization of the instance of document format handler.
Public methodIsRedactionAccepted
Checks for IRedactionCallback implementation and invokes it, if specified.
Public methodLoad
Loads the document from a stream.
Protected methodMemberwiseClone (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 (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