Jump to content

FastReport on standalone server


markokas
 Share

Recommended Posts

Dear all,

 

I developed application using UniGUI as standalone web server, using Delphi XE2, win 7 32 bit.

To make reports I have used FastReports, but it works normally only in the VCL mode.

On the web mode get access violation or report is not make correctly. The printer is available/installed.

As I read the Fastreports are thread safe. Is it possible to use Fastreport in webmode?

Maybe is possible to make report only in VCL session (so web sessions calls VCL sesion to make reports)?

Do you have some example, workaround, or what is the best practice to make PDF report?

 

Sample code

 

sql:='select * from tablename';
// open AdoQuery - Rlogpst is connected to TFrxDbDataset
Rlogpst.Close;
Rlogpst.sql.Text:=sql;
Rlogpst.Open;
// loading fastreport design from file
report.LoadFromFile(ExtractFilepath(paramStr(0))+'porociloSIu.fr3') ;
// assign some variables in fastreport
report.Variables[' xx']:=0;
report.Variables['xy']:=''''+combo1.text+'''';
report.PrintOptions.ShowDialog := False;
report.ShowProgress:=false;
report.PrintOptions.ShowDialog:=false;
report.EngineOptions.SilentMode:=True;
// unique file name
fn:=FormatDateTime('YYMMDD_hhmmnnss',now)+'_'+UniMainModule.ruser+'.pdf';
// set pdf export
pdf.FileName:= UniServerModule.LocalCachePath+fn;
pdf.DefaultPath:=UniServerModule.LocalCachePath;
report.PrepareReport();
report.Export(pdf);
// making a link to download created pdf file
elink.Caption:='<a href="'+UniServerModule.LocalCacheURL+fn+'" target=new>Click to download: ('+fn+')</a>';

 

What could be wrong, it works only in VCL session ...

 

 

Thank you for your help in advance,

 

Best regards,

Marko Kastelic

Link to comment
Share on other sites

Try the following code:

procedure TfrmPrintForm.PrintReport();
begin
 frxPDFExport.FileName := 'ReportXXX_' + FormatDateTime('hhmmss.zzz', Now()) + '.pdf'; // Create a unique name for report. 
 frxPDFExport.DefaultPath := UniServerModule.LocalCachePath; // Export Path;
 frxReport.PrepareReport(); // Create Report
 frxReport.Export(frxPDFExport); // Export Report
 rptURLFrame.URL := UniServerModule.LocalCacheURL + frxPDFExport.FileName; // Displayed on UniURLFrame
end;

Link to comment
Share on other sites

Try the following code:

procedure TfrmPrintForm.PrintReport();
begin
 frxPDFExport.FileName := 'ReportXXX_' + FormatDateTime('hhmmss.zzz', Now()) + '.pdf'; // Create a unique name for report. 
 frxPDFExport.DefaultPath := UniServerModule.LocalCachePath; // Export Path;
 frxReport.PrepareReport(); // Create Report
 frxReport.Export(frxPDFExport); // Export Report
 rptURLFrame.URL := UniServerModule.LocalCacheURL + frxPDFExport.FileName; // Displayed on UniURLFrame
end;

 

I test it also this way, but the problem is not solved .. Works only in VCL in web mode does not work,

it looks like that tfrxDbDataset some how does not work in web mode ...

Link to comment
Share on other sites

Tip:

 

Since you have an AdoQuery you must set ServerModule->AutoCoInitialize->True

 

I set AutoCoInitialize, but is no differenece, in logfile is

 

maps_2009_2010: 0000116C: 11:32:48CommandGet:EUniSessionException : Invalid session or session Timeout.

 

The pdf in localcache is created, but has only header of report - without masterdata

 

br,mk.

Link to comment
Share on other sites

Well, this is not entirely true. Some reports may contain elements which can't be used in multi-thread environment. RichText is one of them.

 

Can you try with a very simple or an empty report and test again?

 

Yes I did,

 

Now it works perfectly, I built report from start (probably something wrong, I have used old *.fr3 from my previous application).

 

Thank you Farshad for your help,

 

Your components are great work!

 

br,mk.

Link to comment
Share on other sites

  • 4 weeks later...

Try the following code:

procedure TfrmPrintForm.PrintReport();
begin
 frxPDFExport.FileName := 'ReportXXX_' + FormatDateTime('hhmmss.zzz', Now()) + '.pdf'; // Create a unique name for report. 
 frxPDFExport.DefaultPath := UniServerModule.LocalCachePath; // Export Path;
 frxReport.PrepareReport(); // Create Report
 frxReport.Export(frxPDFExport); // Export Report
 rptURLFrame.URL := UniServerModule.LocalCacheURL + frxPDFExport.FileName; // Displayed on UniURLFrame
end;

 

Hi All,

 

Is it possible someone could add a small demo like the one for Quickreport ?

 

Everything works fine , the problem is I keep on getting the following error :

 

" File C:\Users\Desktop\Web App\Debug\Win32\cache\Project1\4uzDtQrwZ8Yt8s4\C:Users DesktopWeb AppDebugWin32cacheProject1uzDtQrwZ8Yt8s4\ReportXXX_112604.807.pdf not found. "

 

Thanks for the great components

 

Best regards

Link to comment
Share on other sites

For some reason it is generating the same URL twice.

 

"C:\Users\Desktop\Web App\Debug\Win32\cache\Project1\4uzDtQrwZ8Yt8s4\C:Users DesktopWeb AppDebugWin32cacheProject1uzDtQrwZ8Yt8s4\ReportXXX_112604.80"

 

This works fine without URL

 

pdf.FileName := 'ReportXXX' + FormatDateTime('hhmmss.zzz', Now()) + '.pdf';

report.PrepareReport();

report.Export(pdf);

rptURLFrame.URL := pdf.FileName;

 

thank you

Link to comment
Share on other sites

frxPDFExport1.FileName := 'LapBarang.fr3'+FormatDateTime('hhmmss.zzz',Now())+'.pdf';

frxPDFExport1.DefaultPath := UniServerModule.LocalCachePath;

frxReport1.PrepareReport();

frxReport1.Export(frxPDFExport1);

UniURLFrame1.URL := UniServerModule.LocalCacheURL+frxPDFExport1.FileName;

 

Code is work, but view error : Project1.exe raised exeception class $C00000005 with message 'access violation at 0x876579c5: read of address 0x345sdf

Thank's

Link to comment
Share on other sites

Sorry,

I mean Dialog when we call procedure :

frxPDFExport1.FileName := S;

frxPDFExport1.DefaultPath := UniServerModule.LocalCachePath;

frxReport1.PrepareReport();

frxReport1.Export(frxPDFExport1);

UniURLFrame1.URL := UniServerModule.LocalCacheURL+S;

 

and I mean Taskbar on windows desktop.

Thank's

Link to comment
Share on other sites

  • Administrators

Sorry,

I mean Dialog when we call procedure :

frxPDFExport1.FileName := S;

frxPDFExport1.DefaultPath := UniServerModule.LocalCachePath;

frxReport1.PrepareReport();

frxReport1.Export(frxPDFExport1);

UniURLFrame1.URL := UniServerModule.LocalCacheURL+S;

 

and I mean Taskbar on windows desktop.

Thank's

 

That dialog can only be displayed in VCL mode.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...