Back to Devexpress

IFormatDetectorService Interface

officefileapi-devexpress-dot-xtrarichedit-dot-services-a9a0d633.md

latest2.3 KB
Original Source

IFormatDetectorService Interface

When implemented, allows you to detect the format of the document contained in the stream.

Namespace : DevExpress.XtraRichEdit.Services

Assembly : DevExpress.RichEdit.v25.2.Core.dll

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
public interface IFormatDetectorService
vb
Public Interface IFormatDetectorService

Remarks

Built-in implementation of the IFormatDetectorService service detects supported document formats by file signature, by the structure of the inner zip archive and by the presence of certain elements. You can implement your own format detector and register it as a service for use in your application.

Example

This code snippet uses the IFormatDetectorService.DetectFormat method to determine the format of the document contained in the stream for subsequent loading with the RichEditControl.LoadDocument method.

csharp
using (Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("LoadDocumentExample.TextWithImagesODT"))
    {
    DocumentFormat format = richEditControl1.GetService<IFormatDetectorService>().DetectFormat(stream);
    richEditControl1.LoadDocument(stream, format);
}
vb
Using stream As Stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("LoadDocumentExample.TextWithImagesODT")
    Dim format As DocumentFormat = richEditControl1.GetService(Of IFormatDetectorService)().DetectFormat(stream)
    richEditControl1.LoadDocument(stream, format)
End Using

See Also

IFormatDetectorService Members

DevExpress.XtraRichEdit.Services Namespace