Back to Devexpress

RichEditDocumentServer.BeforeImport Event

officefileapi-devexpress-dot-xtrarichedit-dot-richeditdocumentserver.md

latest4.1 KB
Original Source

RichEditDocumentServer.BeforeImport Event

Occurs before a document is loaded (imported from an external source).

Namespace : DevExpress.XtraRichEdit

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
public event BeforeImportEventHandler BeforeImport
vb
Public Event BeforeImport As BeforeImportEventHandler

Event Data

The BeforeImport event's data class is BeforeImportEventArgs. The following properties provide information specific to this event:

PropertyDescription
DocumentFormatGets the format of the document being loaded.
OptionsProvides access to the importer options.

Remarks

The BeforeImport event enables you to adjust the importer options as required.

Example

csharp
server.BeforeImport += BeforeImportHelper.BeforeImport;
server.LoadDocument("Documents\\TerribleRevengeKOI8R.txt");             

class BeforeImportHelper
{
   public static void BeforeImport(object sender, BeforeImportEventArgs e)
    {
      if (e.DocumentFormat == DocumentFormat.PlainText)
        {
           ((PlainTextDocumentImporterOptions)e.Options).Encoding = Encoding.GetEncoding(20866);
        }
   }
}
vb
AddHandler server.BeforeImport, AddressOf BeforeImportHelper.BeforeImport
server.LoadDocument("Documents\TerribleRevengeKOI8R.txt")            
End Sub

Private Class BeforeImportHelper
   Public Shared Sub BeforeImport(ByVal sender As Object, ByVal e As BeforeImportEventArgs)
                If e.DocumentFormat = DocumentFormat.PlainText Then
                    CType(e.Options, PlainTextDocumentImporterOptions).Encoding = Encoding.GetEncoding(20866)
                End If
   End Sub
End Class

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the BeforeImport event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

word-document-api-examples/CS/CodeExamples/ImportActions.cs#L38

csharp
// Handle the Before Import event.
wordProcessor.BeforeImport += (s, e) =>
{

word-document-api-examples/VB/CodeExamples/ImportActions.vb#L36

vb
' Handle the Before Import event.
AddHandler wordProcessor.BeforeImport,
    Sub(s, e)

Implements

BeforeImport

See Also

DocumentLoaded

LoadDocument

RichEditDocumentServer Class

RichEditDocumentServer Members

DevExpress.XtraRichEdit Namespace