Jump to content

Send file (PDF)


johnp

Recommended Posts

Hello,

 

I am using FastReport with uniGUI. Works OK. I am able to export my report to a PDF and save to the server. I would like to return PDF to the client using sendfile once saved.

 

This is the line of code I have

 

Sendfile.(ExtractFilePath(Application.ExeName) + 'files\' + tempstr1,true);

 

 

I cannot seem to send a file, or get this to work. Does sendfile work? Is there another way?

 

John P.

Link to comment
Share on other sites

You can use this:

 

* I put the fastreport components in my DataModule.

 

* I use this code 'Onclick' button.

 

procedure TfrmMenu.MyFrxShowExp();
var
  fn:String;
  FormUrlView1:TURLFrame;
begin
  fn:= 'R-' +FormatDateTime('hhmmss.zzz', Now()) +'.pdf'; // Create a unique name for report.
  DataModule1.frxReport5.PrintOptions.ShowDialog := False;
  DataModule1.frxReport5.ShowProgress:=false;
  DataModule1.frxReport5.PrintOptions.ShowDialog:=false;
  DataModule1.frxReport5.EngineOptions.SilentMode:=True;
  DataModule1.frxPDFExport1.Background:=True;
  DataModule1.frxPDFExport1.ShowProgress:=False;
  DataModule1.frxPDFExport1.ShowDialog:=False;
  DataModule1.frxPDFExport1.FileName := UniServerModule.LocalCachePath + fn;
  DataModule1.frxPDFExport1.DefaultPath := '';
  if Mainform.WebMode then begin
     DataModule1.frxReport5.PrepareReport(); // Create Report
     DataModule1.frxReport5.Export(DataModule1.frxPDFExport1); // Export Report
     FormUrlView1:=TURLFrame.Create(UniApplication);
     FormUrlView1.URLFrm.URL := UniServerModule.LocalCacheURL + fn; // Displayed on UniURLFrame
     FormUrlView1.Show;
  end else begin
     DataModule1.frxReport5.ShowReport();
  end;
end;

Link to comment
Share on other sites

First thanks for your help. I need further explanation on the use of the var FormUrlView1:TURLFrame; I have not seen TURLFrame before. I am not sure what else I need to create. Do I need to create a special uniGUI frame or view?

 

John

 

BTW Sendfile does not work for me either. Does send file work? I tried a very simple path and the compiler does not recognize sendfile.

 

You can use this:

 

* I put the fastreport components in my DataModule.

 

* I use this code 'Onclick' button.

 

procedure TfrmMenu.MyFrxShowExp();
var
  fn:String;
  FormUrlView1:TURLFrame;
begin
  fn:= 'R-' +FormatDateTime('hhmmss.zzz', Now()) +'.pdf'; // Create a unique name for report.
  DataModule1.frxReport5.PrintOptions.ShowDialog := False;
  DataModule1.frxReport5.ShowProgress:=false;
  DataModule1.frxReport5.PrintOptions.ShowDialog:=false;
  DataModule1.frxReport5.EngineOptions.SilentMode:=True;
  DataModule1.frxPDFExport1.Background:=True;
  DataModule1.frxPDFExport1.ShowProgress:=False;
  DataModule1.frxPDFExport1.ShowDialog:=False;
  DataModule1.frxPDFExport1.FileName := UniServerModule.LocalCachePath + fn;
  DataModule1.frxPDFExport1.DefaultPath := '';
  if Mainform.WebMode then begin
     DataModule1.frxReport5.PrepareReport(); // Create Report
     DataModule1.frxReport5.Export(DataModule1.frxPDFExport1); // Export Report
     FormUrlView1:=TURLFrame.Create(UniApplication);
     FormUrlView1.URLFrm.URL := UniServerModule.LocalCacheURL + fn; // Displayed on UniURLFrame
     FormUrlView1.Show;
  end else begin
     DataModule1.frxReport5.ShowReport();
  end;
end;

Link to comment
Share on other sites

  • 4 months later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...