DocumentFormatInstance
Contents
[
Hide
]
DocumentFormatInstance class
Represents a specific format of a document. Implement this class to add your own document types.
public abstract class DocumentFormatInstance
Properties
Name | Description |
---|---|
Password { get; set; } | Gets or sets a password for password protected documents. |
Methods
Name | Description |
---|---|
virtual Initialize(DocumentFormatConfiguration, RedactorSettings) | Performs initialization of the instance of document format handler. |
IsRedactionAccepted(RedactionDescription) | Checks for IRedactionCallback implementation and invokes it, if specified. |
virtual Load(Stream) | Loads the document from a stream. |
virtual PerformBinaryCheck(Stream) | Checks if the given stream contains a document, supported by this format instance. |
abstract Save(Stream) | Saves the document to a stream. |
Remarks
Learn more
- More details about implementing custom formats: Create custom format handler
Examples
The following example demonstrates how to create an empty stub for a custom format handler.
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.
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
- namespace GroupDocs.Redaction.Integration
- assembly GroupDocs.Redaction