markokas Posted December 20, 2011 Posted December 20, 2011 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 Quote
thecrgrt Posted December 20, 2011 Posted December 20, 2011 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; Quote
markokas Posted December 20, 2011 Author Posted December 20, 2011 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 ... Quote
Administrators Farshad Mohajeri Posted December 20, 2011 Administrators Posted December 20, 2011 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 ... Is there any error message? Can you check uniGUI log file placed under log folder Have you traced your code? Quote
Administrators Farshad Mohajeri Posted December 20, 2011 Administrators Posted December 20, 2011 Tip: Since you have an AdoQuery you must set ServerModule->AutoCoInitialize->True Quote
markokas Posted December 20, 2011 Author Posted December 20, 2011 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. Quote
Administrators Farshad Mohajeri Posted December 20, 2011 Administrators Posted December 20, 2011 As I read the Fastreports are thread safe. 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? Quote
markokas Posted December 20, 2011 Author Posted December 20, 2011 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. Quote
morphine Posted January 18, 2012 Posted January 18, 2012 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 Quote
Administrators Farshad Mohajeri Posted January 18, 2012 Administrators Posted January 18, 2012 rptURLFrame.URL := UniServerModule.LocalCacheURL + frxPDFExport.FileName; // Displayed on UniURLFrame Can you check and see if a valid URL is generated here? Quote
morphine Posted January 18, 2012 Posted January 18, 2012 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 Quote
IdrisZZ Posted January 19, 2012 Posted January 19, 2012 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 Quote
Administrators Farshad Mohajeri Posted January 19, 2012 Administrators Posted January 19, 2012 var S: string; S:= 'LapBarang_'+FormatDateTime('hhmmss.zzz',Now())+'.pdf'; frxPDFExport1.FileName := S; frxPDFExport1.DefaultPath := UniServerModule.LocalCachePath; frxReport1.PrepareReport(); frxReport1.Export(frxPDFExport1); UniURLFrame1.URL := UniServerModule.LocalCacheURL+S; Quote
IdrisZZ Posted January 21, 2012 Posted January 21, 2012 Why dialog print to pdf always hidden on task bar, not view on web and view : ajax error Thank's Quote
Administrators Farshad Mohajeri Posted January 21, 2012 Administrators Posted January 21, 2012 Why dialog print to pdf always hidden on task bar, not view on web and view : ajax error Thank's I'm not sure what dialog you're referring to. Please explain the issue giving more details. Quote
IdrisZZ Posted January 22, 2012 Posted January 22, 2012 I mean : Dialog Form for Export to PDF always hidden on task bar. Quote
Administrators Farshad Mohajeri Posted January 22, 2012 Administrators Posted January 22, 2012 I mean : Dialog Form for Export to PDF always hidden on task bar. Again I'm not quite sure which dialog you're referring. In web mode we don't have a task bar. A VCL dialog can not be displayed in web mode. Those dialogs are only visible on server desktop . Quote
IdrisZZ Posted January 22, 2012 Posted January 22, 2012 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 Quote
Administrators Farshad Mohajeri Posted January 22, 2012 Administrators Posted January 22, 2012 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. Quote
IdrisZZ Posted January 22, 2012 Posted January 22, 2012 I'm Sorry, it's True : "Show Dialog := false;" Thank's Quote
IdrisZZ Posted January 22, 2012 Posted January 22, 2012 By the way, How to setting Project UniGUI For Client Server on the LAN(Local Area Network) ? Thank's Quote
Administrators Farshad Mohajeri Posted January 22, 2012 Administrators Posted January 22, 2012 By the way, How to setting Project UniGUI For Client Server on the LAN(Local Area Network) ? Thank's You simply type IP address of the server in the client browser: For example: http:://192.168.1.100:8077 Quote
IdrisZZ Posted January 22, 2012 Posted January 22, 2012 OK Thank's. So, how to view report on UniURLFrame1 without show dialog VCL Mode ? Quote
Administrators Farshad Mohajeri Posted January 22, 2012 Administrators Posted January 22, 2012 OK Thank's. So, how to view report on UniURLFrame1 without show dialog VCL Mode ? You can't. A VCL dialog can't be displayed in web mode. uniGUI doesn't provide a mean to achieve this. If you need such a dialog then you must design it yourself using uniGUI controls. Quote
maxpetruk Posted January 22, 2012 Posted January 22, 2012 Hello Farshad, Could you show code example, how to download genarated PDF or excel report (by FastReport) instead to show it in UrlFrame? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.