How to get Header/Footer by TRVReportHelper
Posted: Mon Feb 04, 2013 11:54 am
I want to Load a rtf Document in three RVReportHelper (Main, Header & Footer). After that I want to show it on a Dialog (TQDARTFDialogDlg) with three RichViews on it. But in RichViewHeader / RichViewFooter i get the whole Document. What have I missed?
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
var
QDARTFDialog: TQDARTFDialogDlg;
RVRHHeader: TRVReportHelper;
RVRHFooter: TRVReportHelper;
RVRHMain: TRVReportHelper;
RVTmp: TMemoryStream;
begin
inherited;
QDARTFDialog := TQDARTFDruckDlg.Create(nil);
RVRHMain := TRVReportHelper.Create(nil);
RVRHHeader := TRVReportHelper.Create(nil);
RVRHFooter := TRVReportHelper.Create(nil);
RVTmp := TMemoryStream.Create;
// init
RVRHMain.RichView.Style := TRVStyle.Create(RVRHMain.RichView);
RVRHHeader.RichView.Style := TRVStyle.Create(RVRHHeader.RichView);
RVRHFooter.RichView.Style := TRVStyle.Create(RVRHFooter.RichView);
RVRHMain.RichView.DeleteUnusedStyles(True,True,True);
RVRHHeader.RichView.DeleteUnusedStyles(True,True,True);
RVRHFooter.RichView.DeleteUnusedStyles(True,True,True);
// load
RVRHMain.RichView.RTFReadProperties.SetHeader(RVRHHeader.RichView.RVData);
RVRHMain.RichView.RTFReadProperties.SetFooter(RVRHFooter.RichView.RVData);
RVRHMain.RichView.LoadRTF('C:\Sandboxen\work.90\1-TRichView\Vorlagen\Lieferanten.rtf');
try
RVRHMain.RichView.SaveRVFToStream(RVTmp, false);
RVTmp.Position := 0;
QDARTFDialog.RichViewMain.Clear;
QDARTFDialog.RichViewMain.LoadRVFFromStream(RVTmp);
QDARTFDialog.RichViewMain.Format;
// Header
RVRHHeader.RichView.SaveRVFToStream(RVTmp, false);
RVTmp.Position := 0;
QDARTFDialog.RichViewHeader.Clear;
QDARTFDialog.RichViewHeader.LoadRVFFromStream(RVTmp);
QDARTFDialog.RichViewHeader.Format;
// Footer
RVRHFooter.RichView.SaveRVFToStream(RVTmp, false);
RVTmp.Position := 0;
QDARTFDialog.RichViewFooter.Clear;
QDARTFDialog.RichViewFooter.LoadRVFFromStream(RVTmp);
QDARTFDialog.RichViewFooter.Format;
finally
RVTmp.Free;
RVRHMain.Free;
RVRHHeader.Free;
RVRHFooter.Free;
end;
QDARTFDialog.ShowModal;
QDARTFDialog.Free;
end;