vcl-dxrichedit-dot-control-dot-core-dot-tdxricheditcontrolbase-d4054c53.md
Creates a temporary document server.
function CreateDocumentServer: IdxRichEditDocumentServer; overload;
| Type |
|---|
| IdxRichEditDocumentServer |
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;
void __fastcall TMyForm::ResultingDocumentCalculateDocumentVariable(TObject *Sender, TdxCalculateDocumentVariableEventArgs *E)
{
_di_IdxRichEditDocumentServer ADocumentServer;
if(E->VariableName == "Categories")
{
ADocumentServer = recMaster->CreateDocumentServer();
ADocumentServer->AddCalculateDocumentVariableHandler(MasterDocumentServerCalculateDocumentVariable);
recMaster->MailMerge(ADocumentServer->Document);
ADocumentServer->RemoveCalculateDocumentVariableHandler(MasterDocumentServerCalculateDocumentVariable);
E->Value = TValue.From(ADocumentServer);
E->Handled = true;
}
}
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