Recent

Author Topic: lazreport in a server  (Read 9007 times)

tintinux

  • Sr. Member
  • ****
  • Posts: 302
    • Gestinux
lazreport in a server
« on: September 05, 2013, 11:11:37 pm »
Hi

LazReport is good with it's preview and design interface.

But I'd like to use it to produce documents on a server, and for this I should make a small console program, without any graphical functionalities and libraries.

Is it possible ? Is there any compilation directive for this ?

Thanks !
Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

howardpc

  • Hero Member
  • *****
  • Posts: 3176
Re: lazreport in a server
« Reply #1 on: September 05, 2013, 11:36:05 pm »
It might be possible, but I doubt it, because the classes LazReport is built from incorporate several GUI entities at a foundation level: TForm, TPanel, TButton, TScrollBar etc.
It was not designed originally in a way that allows easy (or possibly any) uncoupling from its GUI code.

taazz

  • Hero Member
  • *****
  • Posts: 5363
Re: lazreport in a server
« Reply #2 on: September 06, 2013, 12:20:08 am »
Although it seems that lazReport needs GUI elements that is not true at all.
In my experience the only thing that use forms and gui elements are the designer and the dialogs (preview, printer selection etc) that the unit LR_class is defining.

In any event I'm certain that the engine can be used from a console application with out problems as long as care is taken to configure it properly and avoid modal dialogs and the designer. Having said that it would be probably better if a server type of component was build to allow multiple uses like printing  to a file or connecting from a client and pulling a report preview using tcp/ip etc.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

dgaspary

  • Jr. Member
  • **
  • Posts: 55
Re: lazreport in a server
« Reply #3 on: September 06, 2013, 02:49:54 am »
If you are using linux you can use XVFB [1] .

I have used it with an old java report system which GUI was a requirement.

[1] http://en.wikipedia.org/wiki/Xvfb
« Last Edit: September 06, 2013, 02:54:21 am by dgaspary »

binfch

  • New Member
  • *
  • Posts: 22
Re: lazreport in a server
« Reply #4 on: September 06, 2013, 10:21:04 am »
Hi there

There is another approach that works quiet well for me.

Check the 'Apache FOP' project (http://xmlgraphics.apache.org/fop). It's a Java component that accepts a reporting template (I use the FO Designer from http://www.java4less.com/fopdesigner/fodesigner.php) and an XML data file. Apache FOP then generates the PDF report.

Hope this helps,
Peter

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: lazreport in a server
« Reply #5 on: September 06, 2013, 02:17:16 pm »
LazReport is good with it's preview and design interface.

But I'd like to use it to produce documents on a server, and for this I should make a small console program, without any graphical functionalities and libraries.
You could write a console program with the report components and try and compile it with the widgetset set to NoGUI. This will pull in the LCL but will not pull in widgetset (Qt,GTK,etc) dependencies.
We use this in e.g. the fpcup updater console program where we call LCL functions...
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

otorres

  • Jr. Member
  • **
  • Posts: 94
Re: lazreport in a server
« Reply #6 on: October 02, 2013, 12:38:43 am »
   Yes, is possible, I recently did an application with any number of csv's can generate a report in pdf, of course, is running on windows server, linux as I could not answer.

tintinux

  • Sr. Member
  • ****
  • Posts: 302
    • Gestinux
Re: lazreport in a server
« Reply #7 on: January 07, 2014, 02:26:50 pm »
Hi

I'm trying to follow BigChimp advice.

I can't make exactly a console program (with the wizard), there are too many missing uses and library path.

So, I made an Application and changed the project source to replace the Application.Run by a call to a method creating the report. Is it very different of a console program ?

Compiled with the default Windows widgetset, it works perfectly when I run it from Windows (not from a server, of course).

Compiled with NoGui widgetset, I get an exception : Canvas does not allow drawing
It occurs from within the TFrReport.Create         

trying to
Code: [Select]
SBmp.Canvas.Pixels[i, j] := Clr[(j + i) mod 2];
What can I do ?

Thanks
Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: lazreport in a server
« Reply #8 on: January 07, 2014, 02:54:41 pm »
Compiled with NoGui widgetset, I get an exception : Canvas does not allow drawing
It occurs from within the TFrReport.Create         

trying to
Code: [Select]
SBmp.Canvas.Pixels[i, j] := Clr[(j + i) mod 2];
What can I do ?
Mention your Lazarus version. Perhaps that problem is fixed in a newer version.

Provide a test project that shows the problem. If the problem isn't fixed, it is useful when submitting a bug report so the developers can reproduce the problem...

Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: lazreport in a server
« Reply #9 on: January 07, 2014, 02:57:10 pm »
So, I made an Application and changed the project source to replace the Application.Run by a call to a method creating the report. Is it very different of a console program ?
This seems a bit strange. What I'd suggest is creating a regular Lazarus application, but disabling Win32 GUI application (-WG) in project options, and setting the widgetset to nogui in the target platform (also in project options; location differs per Lazarus version).
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

tintinux

  • Sr. Member
  • ****
  • Posts: 302
    • Gestinux
Re: lazreport in a server
« Reply #10 on: January 07, 2014, 03:46:01 pm »
Thanks for your reply.

I think I made a "regular" Lazarus application.  (File, New, Project/Application).

I replaced the Application.Run by another call to trigger the report creation, and then exit ?
It works fine (with a GUI), why is it strange ?
What else can I do ? 

However the exception is raised before the call or the Application.Run (if I restore it), when the report is created, during the creation of the form containing it.

Even after I clear the Win32 GUI application checkbox, I have the same exception.

Regards




« Last Edit: January 07, 2014, 04:23:14 pm by tintinux »
Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: lazreport in a server
« Reply #11 on: January 07, 2014, 03:58:13 pm »
Application.Run sets various options IIRC.
Code: [Select]
procedure TApplication.Run;
begin
  if (FMainForm <> nil) and FShowMainForm then FMainForm.Show;
  WidgetSet.AppRun(@RunLoop);
end;

no idea if that has an influence on your report...
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: lazreport in a server
« Reply #12 on: January 07, 2014, 04:00:50 pm »
Perhaps looking at the tachart nogui demo will help:
$(lazarusdir)\components\tachart\demo\nogui
... they're also trying to use graphical components without display..
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

tintinux

  • Sr. Member
  • ****
  • Posts: 302
    • Gestinux
Re: lazreport in a server
« Reply #13 on: January 08, 2014, 02:13:10 pm »
Sorry, BigChimp, I have not seen one of your answers.

I'm using Lazarus 1.0.14 (and I can't access to SVN from where I am).

I have attached a small project which does the same as LazReport OnCreate (in LR_Class.pas), and raises the same error when NoGui widgetset is selected.

I do not understand why we could not create and draw a bitmap with this widgetset, but I do not master this topic enough to know if it is a bug or if I do something wrong.

Thanks for your help.
Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

howardpc

  • Hero Member
  • *****
  • Posts: 3176
Re: lazreport in a server
« Reply #14 on: January 08, 2014, 06:27:40 pm »
You can create a TBitmap using the FCL/LCL and the nogui widgetset, but you cannot display it, since (by definition) you have no gui.
If you look at the constructor of TfrReport you'll see that in its initialisation it creates a TfrProgressForm, which of course immediately raises a segmentation fault if you have specified the nogui widgetset. Attempting to create a form with no gui is an impossibility.
As I pointed out earlier, TfrReport is completely wedded to a windowed gui by its design.
Perhaps the gui parts could be extracted and removed, but it would require a complete rewrite of the component before it would ever work without its present gui-dependency.