Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TdxRichEditControlBase.CreateDocumentServer Method

Creates a temporary document server.

#Declaration

Delphi
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