#1 2015-10-01 02:05:56

Celso
Member
Registered: 2013-05-14
Posts: 55

Send a PDF File from server

Hi,

I am generating a report on the server side with FastReport. How do I send the generated report to the client through the following function:

ILongWorkCallback = interface(IInvokable)
    ['{C443AF11-E137-43D3-AB75-1CEC17FE30B2}']
    procedure WorkFinished(const worktype : Integer;
                                 timeTaken: integer;
                           const AResult: ??????);

Offline

#2 2015-10-01 06:47:43

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Send a PDF File from server

You could use RawByteString, but it would use Base64 encoding during the transport.

An alternative may be to supply an ID of the report, then download the content from the main service, directly as binary using http://synopse.info/files/html/Synopse% … #TITLE_434

Offline

#3 2015-10-01 14:32:41

Celso
Member
Registered: 2013-05-14
Posts: 55

Re: Send a PDF File from server

Thanks for the feedback.
so I used and it worked:

Interface:
  ILongWorkCallback = interface(IInvokable)
    ['{C443AF11-E137-43D3-AB75-1CEC17FE30B2}']
    procedure WorkFinished(const worktype : Integer;
                                 timeTaken: integer;
                           const AResult:  RawByteString);

Server:
AStream: TRawByteStringStream

frxPDFExport.Stream := AStream;
frxPDFExport.ShowDialog := False;
frxReport.PrepareReport(True);
frxReport.Export(AfrxPDFExport);

AStream.seek(0,soBeginning);

fCallback.WorkFinished(fWorktype,GetTickCount64 - ftix,AStream.DataString);

Client:
v_Stream  : TMemoryStream;

v_Stream := TMemoryStream.Create;
WriteStringToStream(v_Stream,AResult);
v_Stream.Position := 0;
v_Stream.SaveToFile(v_filename);
v_Stream.Free;

Offline

#4 2015-10-01 18:15:05

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Send a PDF File from server

You may have used the FileFromString() function of SynCommons, instead of using a TMemoryStream.

Offline

Board footer

Powered by FluxBB