Hi
Im trying to implement a method that can merge the bodypart of a document (stored in the filesystem) at the end of an existing document. The existing document can be with/without header/footers information, but at all time only bodypart should be merged. I made the following methods but even though the merge-memorystream contains data, it doesn't seem to get inserted. What Im I doing wrong, or should I do it in another way?
FYI, the document are .rtf poss. with unicode text.
Code
function fnMergeDocuments(strFileNamePath: String): Boolean;
var
rteTmpEditor: TWPRichText;
stmMergeFile: TMemoryStream;
begin
Result := True;
// init
stmMergeFile := TMemoryStream.Create;
rteTmpEditor := TWPRichText.Create(Self);
// load merge file into temp editor
if Result then
begin
try
rteTmpEditor.LoadFromFile(strFileNamePath);
rteTmpEditor.ReformatAll(True);
except
Result := False;
end;
end;
// merge
if Result then
begin
// lock screen
rteEditor.LockScreen;
try
// goto end of origional document (body)
rteEditor.WorkOnText := wpBody;
rteEditor.HideSelection;
rteEditor.CPPosition := MaxInt;
// merge
if rteTmpEditor.SaveToStream(stmMergeFile, 'RTF') then
rteEditor.LoadFromStream(stmMergeFile, 'RTF');
// force update
rteEditor.ReformatAll(True);
finally
rteEditor.UnLockScreen(True);
end;
end;
// free mem
if Assigned(rteTmpEditor) then
rteTmpEditor.Free;
if Assigned(stmMergeFile) then
stmMergeFile.Free
end;
Alles anzeigen