Initialize

DocumentFormatInstance.Initialize method

Performs initialization of the instance of document format handler.

public virtual void Initialize(DocumentFormatConfiguration config, RedactorSettings settings)
Parameter Type Description
config DocumentFormatConfiguration Format configuration
settings RedactorSettings Default settings for redaction process.

Examples

The following example demonstrates how to use the initialization data.

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