Difference between revisions of "FPReport FAQ"

From Free Pascal wiki
Jump to navigationJump to search
(→‎FPC FPReport: Infos from Bug 0036545 and 0036525)
 
(3 intermediate revisions by 2 users not shown)
Line 6: Line 6:
  
 
=== FPReport <> LazReport ===
 
=== FPReport <> LazReport ===
FPReport is not LazReport!! These are two different reporting systems.  
+
 
 +
FPReport is not LazReport! These are two different reporting systems.  
 
* LazReport is based on FreeReport 2.32, see [[LazReport_Documentation]].  
 
* LazReport is based on FreeReport 2.32, see [[LazReport_Documentation]].  
 
* FPReport is written from scratch, see [[FPReport]] documentation.
 
* FPReport is written from scratch, see [[FPReport]] documentation.
  
 
=== Papermanager must registered ===
 
=== Papermanager must registered ===
 +
 
You never registered the standard page sizes with:
 
You never registered the standard page sizes with:
<syntaxhighlight>
+
 
 +
<syntaxhighlight lang="pascal">
 
   if PaperManager.PaperCount=0 then
 
   if PaperManager.PaperCount=0 then
 
     PaperManager.RegisterStandardSi
 
     PaperManager.RegisterStandardSi
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 
=== Fontmanager ===
 
=== Fontmanager ===
 +
 
Your report used LiberationSans font. Make sure you added the search paths to the font cache. eg:
 
Your report used LiberationSans font. Make sure you added the search paths to the font cache. eg:
<syntaxhighlight>
+
 
 +
<syntaxhighlight lang="pascal">
 
   {$IFDEF UNIX}
 
   {$IFDEF UNIX}
 
     gTTFontCache.SearchPath.Add(GetUserDir + '.fonts/');
 
     gTTFontCache.SearchPath.Add(GetUserDir + '.fonts/');
Line 25: Line 31:
 
   {$ENDIF}
 
   {$ENDIF}
 
</syntaxhighlight>
 
</syntaxhighlight>
In windows this useable
+
 
<syntaxhighlight>
+
In windows this is usable:
 +
 
 +
<syntaxhighlight lang="pascal">
 
   gTTFontCache.ReadStandardFonts;
 
   gTTFontCache.ReadStandardFonts;
 
   gTTFontCache.BuildFontCache;
 
   gTTFontCache.BuildFontCache;
Line 34: Line 42:
 
* '''Unix''' LiberationSans
 
* '''Unix''' LiberationSans
 
* '''Windows''' Arial
 
* '''Windows''' Arial
* '''Not unix and not windows''' Helvetica
+
* '''Not Unix and not windows''' Helvetica
  
On some enviroments like Rasbian you have troubles with this defaults !! You see then a message, the font is not found and the report is not generated.
+
In some environments like Raspbian you may have trouble with the defaults! You may see a message that the font is not found and the report is not generated.
  
 
== FPC FPReport ==
 
== FPC FPReport ==
 +
 
=== I did not find FPReport in my FPC dir ===
 
=== I did not find FPReport in my FPC dir ===
It is located in the FPC\packages\fcl-report dir, but only in FPC trunk (=3.1.1) since rev. 36962 (20.Aug. 2017)
+
 
 +
It is located in the FPC\packages\fcl-report dir, but only in FPC trunk (=3.1.1) since rev. 36962 (20 Aug 2017).
  
 
=== What is the minimum requirement ===
 
=== What is the minimum requirement ===
Info from Mailinglist - FPC 2.6.4 (and Lazarus 1.6.2), but you will need to copy some additional units from the
+
 
trunk version of the FPC source repo (in particular, fpexprpars, and fcl-pdf) and the Lazarus trunk repro too
+
Info from the mailing list - FPC 2.6.4 (and Lazarus 1.6.2), but you will need to copy some additional units from the
 +
trunk version of the FPC source repo (in particular, fpexprpars, and fcl-pdf) and the Lazarus trunk repo too.
  
 
=== Expression and Variables ===
 
=== Expression and Variables ===
If you use float variables and stringvalues on a non english configured system you have problems with the comma as decimalseperator (eg. german configured computer). All results will have a dot instead of the the configured value in Formatsetting. This is by design (see Bugreport 0036545 and 0036525) !!
+
 
 +
If you use float variables and string values on a non-English configured system you will have problems with the comma as a decimal separator (eg German configured computer). All results will have a dot instead of the the configured value in format setting. This is by design (see Bug report 0036545 and 0036525)!
 +
 
 +
''Explanation:''
 +
The Value property of a variable is written to the JSON or XML when saving/loading the report: see ReadElement/WriteElement.
 +
So it must be in a transportable, locale-neutral format.
 +
 
 +
Imagine saving the report to stream and in a File or DB Blob field, then loading it on another PC with different locale settings.
 +
If the stream is written with decimal separator, and read with decimal separator there will be an error on load.
 +
 
 +
See also SetValue() where Val() is used to create the value from a string.
  
 
== Lazarus FPReport ==
 
== Lazarus FPReport ==
=== I did not find FPReport in my Lazarus dir ===
+
 
Only in Lazarus trunk since rev. 55719 (20.Aug. 2017). Look in LAZARUSDIR\components\fpreport there is a runtimepackage lclfpreport.lpk.
+
=== I did not find FPReport in my Lazarus directory ===
 +
 
 +
Only in Lazarus trunk since rev. 55719 (20 Aug 2017). Look in LAZARUSDIR\components\fpreport there is a runtimepackage lclfpreport.lpk.
  
 
=== I cannot compile the FPReport packages ===
 
=== I cannot compile the FPReport packages ===
As of 20th January 2019 FPReport does not compile out of the box in 64 bit Lazarus (Windows version at least).  It should compile flawlessly in 32 bit Lazarus, though (see also "I did not find FPReport in my Lazarus dir").
 
  
=== Lazarus does not start anymore ===
+
As of 20th January 2019 FPReport does not compile out of the box in 64 bit Lazarus (Windows version at least).  It should compile flawlessly in 32 bit Lazarus, though (see also "I did not find FPReport in my Lazarus directory" above).
 +
 
 +
=== Lazarus does not start anymore in Windows ===
 +
 
 
You need to copy freetype-6.dll and zlib1.dll to your LAZARUSDIR (the folder where lazarus.exe resides). Make sure you use 32 bit DLLs with 32 bit Lazarus and 64 bit DLLs with 64 bit Lazarus. These DLLs are not included. Please see the FreeType [https://www.freetype.org/] and Zlib [https://www.zlib.net/] project pages for details on how to get them. ''Please note that FPReport expects a  "freetype'''-6'''.dll"  whereas the install package from freetype.org includes a  "freetype6.dll"  (without the dash) or a  "freetype.dll", so you have to rename the file to "freetype-6.dll" before starting Lazarus.''
 
You need to copy freetype-6.dll and zlib1.dll to your LAZARUSDIR (the folder where lazarus.exe resides). Make sure you use 32 bit DLLs with 32 bit Lazarus and 64 bit DLLs with 64 bit Lazarus. These DLLs are not included. Please see the FreeType [https://www.freetype.org/] and Zlib [https://www.zlib.net/] project pages for details on how to get them. ''Please note that FPReport expects a  "freetype'''-6'''.dll"  whereas the install package from freetype.org includes a  "freetype6.dll"  (without the dash) or a  "freetype.dll", so you have to rename the file to "freetype-6.dll" before starting Lazarus.''
  
Line 62: Line 87:
  
 
=== My Report does not run/start in Windows ===
 
=== My Report does not run/start in Windows ===
Start the application from the console, so you can see if some dll's are missing. Normally freetype-6.dll and zlib1.dll are missing. For more information look into the README.txt.
+
 
 +
Start the application from the console, so you can see if some dll's are missing. Normally freetype-6.dll and zlib1.dll are missing. For more information read the README.txt. On FPC 3.3.1 it is freetype.dll instead of freetype-6.dll. Use the correct version for your bitness (32 or 64 Bit)
  
 
=== My Font is not found in windows ===
 
=== My Font is not found in windows ===
You have to use the PostScriptName of the font. Eg. under windows you have the font 'Arial' - this is one of the standard font - but you have to write Memo.Font.Name := 'ArialMT' because ArialMT is the correct PostScriptname.
 
  
<syntaxhighlight>
+
You have to use the Postscript name of the font. For example, under Windows you have the font 'Arial' - this is one of the standard fonts - but you have to write Memo.Font.Name := 'ArialMT' because ArialMT is the correct Postscript name.
 +
 
 +
<syntaxhighlight lang="pascal">
 
   for i:= 0 to gTTFontCache.Count-1 do begin
 
   for i:= 0 to gTTFontCache.Count-1 do begin
 
     try
 
     try

Latest revision as of 23:59, 10 January 2020

English (en)

General

Read the README.txt file

Before you compile the FPReport, have a look at the README.txt

FPReport <> LazReport

FPReport is not LazReport! These are two different reporting systems.

Papermanager must registered

You never registered the standard page sizes with:

  if PaperManager.PaperCount=0 then
    PaperManager.RegisterStandardSi

Fontmanager

Your report used LiberationSans font. Make sure you added the search paths to the font cache. eg:

  {$IFDEF UNIX}
    gTTFontCache.SearchPath.Add(GetUserDir + '.fonts/');
    gTTFontCache.SearchPath.Add('/data/devel/Wisa/fonts/Liberation/');
    gTTFontCache.BuildFontCache;
  {$ENDIF}

In windows this is usable:

  gTTFontCache.ReadStandardFonts;
  gTTFontCache.BuildFontCache;

Default Fonts (cDefaultFont and ReportDefaultFont) on

  • Unix LiberationSans
  • Windows Arial
  • Not Unix and not windows Helvetica

In some environments like Raspbian you may have trouble with the defaults! You may see a message that the font is not found and the report is not generated.

FPC FPReport

I did not find FPReport in my FPC dir

It is located in the FPC\packages\fcl-report dir, but only in FPC trunk (=3.1.1) since rev. 36962 (20 Aug 2017).

What is the minimum requirement

Info from the mailing list - FPC 2.6.4 (and Lazarus 1.6.2), but you will need to copy some additional units from the trunk version of the FPC source repo (in particular, fpexprpars, and fcl-pdf) and the Lazarus trunk repo too.

Expression and Variables

If you use float variables and string values on a non-English configured system you will have problems with the comma as a decimal separator (eg German configured computer). All results will have a dot instead of the the configured value in format setting. This is by design (see Bug report 0036545 and 0036525)!

Explanation: The Value property of a variable is written to the JSON or XML when saving/loading the report: see ReadElement/WriteElement. So it must be in a transportable, locale-neutral format.

Imagine saving the report to stream and in a File or DB Blob field, then loading it on another PC with different locale settings. If the stream is written with decimal separator, and read with decimal separator there will be an error on load.

See also SetValue() where Val() is used to create the value from a string.

Lazarus FPReport

I did not find FPReport in my Lazarus directory

Only in Lazarus trunk since rev. 55719 (20 Aug 2017). Look in LAZARUSDIR\components\fpreport there is a runtimepackage lclfpreport.lpk.

I cannot compile the FPReport packages

As of 20th January 2019 FPReport does not compile out of the box in 64 bit Lazarus (Windows version at least). It should compile flawlessly in 32 bit Lazarus, though (see also "I did not find FPReport in my Lazarus directory" above).

Lazarus does not start anymore in Windows

You need to copy freetype-6.dll and zlib1.dll to your LAZARUSDIR (the folder where lazarus.exe resides). Make sure you use 32 bit DLLs with 32 bit Lazarus and 64 bit DLLs with 64 bit Lazarus. These DLLs are not included. Please see the FreeType [1] and Zlib [2] project pages for details on how to get them. Please note that FPReport expects a "freetype-6.dll" whereas the install package from freetype.org includes a "freetype6.dll" (without the dash) or a "freetype.dll", so you have to rename the file to "freetype-6.dll" before starting Lazarus.

There is a breaking change, the library must be "freetype.dll" in newer versions of fpc (actual fixes32 and trunk)

My Report does not run/start in Windows

Start the application from the console, so you can see if some dll's are missing. Normally freetype-6.dll and zlib1.dll are missing. For more information read the README.txt. On FPC 3.3.1 it is freetype.dll instead of freetype-6.dll. Use the correct version for your bitness (32 or 64 Bit)

My Font is not found in windows

You have to use the Postscript name of the font. For example, under Windows you have the font 'Arial' - this is one of the standard fonts - but you have to write Memo.Font.Name := 'ArialMT' because ArialMT is the correct Postscript name.

  for i:= 0 to gTTFontCache.Count-1 do begin
    try
      Memo1.Append(TFPFontCacheItem(gTTFontCache.Items[i]).HumanFriendlyName +'...'+ TFPFontCacheItem(gTTFontCache.Items[i]).PostScriptName);
    except
      Memo1.Append('ERROR in...'+ TFPFontCacheItem(gTTFontCache.Items[i]).FileName)
    end;
  end;