Back to Devexpress

RichEditDocumentServer.SaveDocument(DocumentFormat, EncryptionSettings) Method

officefileapi-devexpress-dot-xtrarichedit-dot-richeditdocumentserver-dot-savedocument-x28-devexpress-dot-xtrarichedit-dot-documentformat-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-encryptionsettings-x29.md

latest3.2 KB
Original Source

RichEditDocumentServer.SaveDocument(DocumentFormat, EncryptionSettings) Method

Saves the document to a byte array in the specified file format and encrypts it with a password.

Namespace : DevExpress.XtraRichEdit

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
public byte[] SaveDocument(
    DocumentFormat documentFormat,
    EncryptionSettings encryptionSettings
)
vb
Public Function SaveDocument(
    documentFormat As DocumentFormat,
    encryptionSettings As EncryptionSettings
) As Byte()

Parameters

NameTypeDescription
documentFormatDocumentFormat

An enumeration member that specifies the output document format.

| | encryptionSettings | EncryptionSettings |

Specifies encryption settings.

|

Returns

TypeDescription
Byte[]

A byte array that contains encrypted data in the specified format.

|

Remarks

You can use this SaveDocument method overload to store a document in an external database.

csharp
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
// ...

using (RichEditDocumentServer wordProcessor = new RichEditDocumentServer())
{
    // Specify encryption settings.
    EncryptionSettings encryptionSettings = new EncryptionSettings
    {
        Type = EncryptionType.Strong,
        Password = "password"
    };

// Save the document to a byte array.
byte[] docBytes = wordProcessor.SaveDocument(DocumentFormat.Docx, encryptionSettings);
}
vb
Imports DevExpress.XtraRichEdit
Imports DevExpress.XtraRichEdit.API.Native
' ...

Using wordProcessor As New RichEditDocumentServer()
    ' Specify encryption settings.
    Dim encryptionSettings As New EncryptionSettings With {
        .Type = EncryptionType.Strong,
        .Password = "password"
    }

' Save the document to a byte array.
Dim docBytes() As Byte = wordProcessor.SaveDocument(DocumentFormat.Docx, encryptionSettings)
End Using

Implements

SaveDocument(DocumentFormat, EncryptionSettings)

See Also

RichEditDocumentServer Class

RichEditDocumentServer Members

DevExpress.XtraRichEdit Namespace