Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating and showing PDF
#3
(06-15-2022, 02:49 AM)DanBarclay Wrote: I don't use Fast Report, but I have followed conversations here regarding threading issues with that lib.  It is not intended for multi threading like a web server.  The solution is to use the CGIRunner component and place the report code in a single thread project.

Check here:

  https://www.atozed.com/forums/showthread...02#pid2402

Note that in post 9 of that thread, Jose has posted a link to sample code.

Dan

There is no threading issues with fastreport if you set all of these settings.

      // this code is very important and needs to be called right after the report is created.
      lFrxReport.EngineOptions.EnableThreadSafe    := True;
      lFrxReport.EngineOptions.UseGlobalDataSetList := False;
      lFrxReport.ReportOptions.Compressed          := True;
      lFrxReport.EngineOptions.SilentMode          := True;
      lFrxReport.EngineOptions.DestroyForms        := False;
      lFrxReport.EngineOptions.UseFileCache        := False;
      lFrxReport.ShowProgress                      := False;

Here is also a procedure for using ReportBuilder if anyone needs it.

procedure fxProcess_Report(ARBreport:TppReport;Output_typeConfusedtring; Send_Stream:boolean=false;AFileNameConfusedtring='';APdfPasswordConfusedtring='');
var lFileName,
lURL,
lFileDirConfusedtring;
lMS : TMemoryStream;
lPDFDevice: TppPDFDevice;
begin


try
with ARBreport do
begin
AllowPrintToFile := False;
ShowPrintDialog := False;
TextFileName := lFileDir;
DeviceType := 'PDF';
ModalCancelDialog := false;
ModalPreview := false;
ShowCancelDialog := false;
lMS := TMemoryStream.Create;
lPDFDevice := TppPDFDevice.Create(nil);
try
lPDFDevice.PDFSettings := ARBreport.PDFSettings;
lPDFDevice.OutPutSTream := lMS;
lPDFDevice.Publisher := ARBreport.publisher;
ARBreport.PrintToDevices;
lURL := IWappCache.TIWAppCache.StreamToCacheFile(WebApplication, lMS, TIWMimeTypes.GetAsString('.' + 'PDF'), ctSession);
WebApplication.NewWindow( lURL
, 'Report'
, 0
, 0
, [woResizable, woDetectBlock]
);

finally
lPDFDevice.free;
lMS.free;
end;
end;
except
raise;
end;



end;
Reply


Messages In This Thread
Creating and showing PDF - by David1 - 06-14-2022, 03:39 PM
RE: Creating and showing PDF - by DanBarclay - 06-15-2022, 02:49 AM
RE: Creating and showing PDF - by joelcc - 06-16-2022, 02:23 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)