views:

385

answers:

2

We use Intraweb for our Web Applications and also have been using ReportBuilder for reporting for our internal windows applications. We also have ExtraDevices which we've used to allow us to save our ReportBuilder reports as Excel files.

Now, I am want to produce a report on our web applications as a PDF file. I have an example on how that is done with ExtraDevices. However, how does the following example get changed with Intraweb?

procedure TWebModule1.WebModule1WebActionItem1Action(Sender: TObject; Request:
  TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
  HD: TPDFDevice;
  MS: TMemoryStream;
begin
  MS := TMemoryStream.Create;
  HD := TPDFDevice.Create(Self);
  HD.PrintToStream := True;
  HD.ReportStream := MS;
  HD.Publisher := Rpt.Publisher;
  Rpt.PrintToDevices;
  Response.ContentType := HD.ContentType;
  Response.ContentStream := MS;
  Response.SendResponse;
  HD.Free;
end;
A: 

Have you seen the RaveDemo that ships with Intraweb? I believe it does what you're looking for but with Rave Reports. I used it to build an Intraweb ReportBuilder PDF version a while back.

I'm not sure if it streams the report though. It's been a while since I looked at it but I think it may save it to disk rather than send the response from memory like your example.

LachlanG
I will take a look at it. But of course I'm wanting to stick with ReportBuilder since that is what we've been using for a while.
dmillam
No need to change to Rave. I use Reportbuilder myself. The code is relatively easy to adapt from Rave to Reportbuilder.
LachlanG
A: 

I think I found the answer to my question. I simply need to use TIWApplication.SendStream.

The code would be modified this way:

procedure TfrmSomeIWForm.SomeBtnClick(Sender: TObject);
var
  HD: TPDFDevice;
  MS: TMemoryStream;
begin
  MS := TMemoryStream.Create;
  HD := TPDFDevice.Create(Self);
  HD.PrintToStream := True;
  HD.ReportStream := MS;
  HD.Publisher := Rpt.Publisher;
  Rpt.PrintToDevices;
  WebApplication.SendStream(MS,false,HD.ContentType);
  HD.Free;
end;
dmillam