views:

326

answers:

1

I am using Delphi 7. I have the reporting mechanism implemented using Rave. Also exporting to HTML, PDF and TXT is used. There is a problem though: When user saves report into file directly (without previewing it first), file extension is not added to the filename by Rave. So the file created looks like Report (instead of Report.pdf) and user needs to specify application to view this report manualy. In order to solve this problem I wrote the following code to RvSystem1 BeforeRrint event:

procedure TRepAllForm.RvSystem1BeforePrint(Sender: TObject);
begin
     if RvSystem1.ReportDest=rdFile then
        RVSystem1.OutputFileName:=RVSystem1.OutputFileName+'.pdf';
End;

But the problem is what if user selects different format? Does anybody know how to identify which rendering user selects? i.e. HTML, PDF or TXT?

Thank you, Tofig Hasanov

+1  A: 

Seems that I have found solution myself ) I used RenderObject property of RVSystem. Here is the code:

procedure TRepAllForm.RvSystem1BeforePrint(Sender: TObject);

begin

 if RvSystem1.ReportDest=rdFile then
 Begin
     if RVSystem1.RenderObject=RvRenderPDF1 then
      RvSystem1.OutputFileName:=RvSystem1.OutputFileName+'.pdf'
     else if RvSystem1.RenderObject=RvRenderHTML1 then
      RvSystem1.OutputFileName:=RvSystem1.OutputFileName+'.html'
     else if RvSystem1.RenderObject=RvRenderText1 then
      RvSystem1.OutputFileName:=RvSystem1.OutputFileName+'.txt';

 End;

end;

Tofig Hasanov