Skip to main content

TdxRichEditControlBase.CreateDocumentServer Method

Creates a temporary document server.

Declaration

function CreateDocumentServer: IdxRichEditDocumentServer; overload;

Returns

Type
IdxRichEditDocumentServer

Remarks

Call this function to create a temporary document server to edit a copy of the opened document and leave the source document unchanged. This can be useful if you need to assemble complex tables with a master-detail relationship during a mail merge operation. The following code example shows an OnCalculateDocumentVariable event handler that uses a temporary document server to generate a document:

procedure TMyForm.ResultingDocumentCalculateDocumentVariable(Sender: TObject; E: TdxCalculateDocumentVariableEventArgs);
var
  ADocumentServer: IdxRichEditDocumentServer;
begin
  if E.VariableName = 'Categories' then
  begin
    ADocumentServer := recMaster.CreateDocumentServer;
    ADocumentServer.AddCalculateDocumentVariableHandler(MasterDocumentServerCalculateDocumentVariable);
    recMaster.MailMerge(ADocumentServer.Document);
    ADocumentServer.RemoveCalculateDocumentVariableHandler(MasterDocumentServerCalculateDocumentVariable);
    E.Value := TValue.From(ADocumentServer);
    E.Handled := True;
  end;
end;

The CreateDocumentServer function exposes the created document server via the IdxRichEditDocumentServer interface. Refer to the interface description for detailed information on available options.

Note

A temporary document server is automatically destroyed once an application exits the method where the CreateDocumentServer function was called. Use the TdxRichEditDocumentServer component if you need a permanent document server.

See Also