vbdavie Posted October 1, 2015 Posted October 1, 2015 There are two issues here. 1. How to get FastReports to generate a PDF file for output? 2. Why does the PDF have missing graphics when viewing on an IPAD? I will discuss each of these. I will make assumptions that you know what the frReport object is, and what the frxPDFExport pas file is. FastReports into a PDF File: I had looked at tons of forum threads from all over and they all had "similar" properties to set. They weren't all the same. So, I mashed them all together into a working piece. There are two variables that I look at in order to determine if I should SEND the file to the browser or to stick the PDF into a URLFrame. These variables are " FDownLoad" and "FUniURLFrame". procedure TFReports.PreviewModal(Const QR:TfrxReport);var fn:String; thr:TThread;Begin Try fn:= 'R-' +FormatDateTime('hhmmss.zzz', Now()) +'.pdf'; // Create a unique name for report. there are much better ways QR.PrintOptions.ShowDialog:=false; QR.PreviewOptions.AllowEdit:=False; QR.ShowProgress:=False; frxPDFExport1.OverwritePrompt:=False; frxPDFExport1.OpenAfterExport:=False; frxPDFExport1.Background:=True; frxPDFExport1.ShowProgress:=False; frxPDFExport1.EmbeddedFonts:=True; frxPDFExport1.ShowDialog:=False; frxPDFExport1.FileName := UniServerModule.LocalCachePath +fn; // Your session unique PDF filename frxPDFExport1.DefaultPath := ''; QR.EngineOptions.SilentMode := True; QR.EngineOptions.EnableThreadSafe := True; QR.EngineOptions.DestroyForms:= False; QR.EngineOptions.UseFileCache:= False; thr:= TThread.CurrentThread; QR.EngineOptions.ReportThread:=thr; // You can't use the global data set list, so they must be added manually // My report uses 7 data sets QR.EngineOptions.UseGlobalDataSetList:=False; QR.EnabledDataSets.Clear; QR.EnabledDataSets.Add(frxDBDataSet1); QR.EnabledDataSets.Add(frxDBDataSet2); QR.EnabledDataSets.Add(frxDBDataSet3); QR.EnabledDataSets.Add(frxDBDataSet4); QR.EnabledDataSets.Add(frxDBDataSet5); QR.EnabledDataSets.Add(frxDBDataSet6); QR.EnabledDataSets.Add(frxDBDataSet7); QR.PrepareReport(); // Create Report QR.Export(frxPDFExport1); // Export Report // Reset to normal operations frxPDFExport1.OpenAfterExport:=True; frxPDFExport1.OverwritePrompt:=True; frxPDFExport1.ShowProgress:=True; frxPDFExport1.ShowDialog:=True; FDownLoad:=False; if FDownLoad Or (FUniURLFrame=Nil) then begin UniSession.SendFile(UniServerModule.LocalCachePath +fn, fn); end else begin FuniURLFrame.URL := UniServerModule.LocalCacheURL +fn; // Displayed on UniURLFrame FuniURLFrame.Show; end; Finally Self.Free; // DECIDE HOW YOU WANT TO FREE THE REPORT OBJECT!!!!! End;End; PDF Images MISSING when viewing on an IPAD? This fix is simple and REQUIRES that you have the source code for FastReports. More specifically, that you have the source code for frxExportPDF.pas. Go into the source file and change one line of code. Yup, that's it. There will be a line of code that looks like this.... '/H ' + IntToStr(TempBitmap.Height) + #13#10'/CS /RGB'#13#10'/BPC 8'#13#10'/I true'#13#10'/F [/DCT]'#13#10'ID'#13#10); CHANGE IT so that it looks like this... '/H ' + IntToStr(TempBitmap.Height) + #13#10'/CS /RGB'#13#10'/BPC 8'#13#10'/I true'#13#10'/F [/DCT]'#13#10'ID '); The old bad code had an extra CR/LF at the end of the line. Huh, who would have thunk. NOTE: You will need to INCLUDE this frxExportPDF.pas file as part of your project, otherwise you will be linking in the old buggy version of the code. Seems obvious, but thiought I would mention it. NOTE: If you do NOT have the source for that file, then there are a fiew links that may be of interest to you. http://synopse.info/forum/viewtopic.php?id=781 http://synopse.info/forum/viewtopic.php?pid=4763 https://www.fast-report.com/en/forum/index.php?showtopic=10148 Hope this helps anybody that's having PDF/FastReport issues. Davie 3 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.