Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-01

[ISSUE] FCL-Web and LazReport

37 messages · 8 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Sven Barth
to Michael Van Canneyt
Michael Van Canneyt wrote
Some time ago, I started a new reporting engine exactly for this reason.

And how far is your progress with that? Which reminds me that I should finally test the new database search provided in packages... -.-

A well-designed reporting engine is independent of any widget set. (see e.g. jasperreports in Java)

Fully agreed here. :)

Regards,
Sven

Reply by email

Michael Van Canneyt
to Sven Barth
Sven Barth wrote 5 lines
Am 17.01.2013 08:52, schrieb Michael Van Canneyt: > Some time ago, I started a new reporting engine exactly for this reason. > And how far is your progress with that? Which reminds me that I should finally test the new database search provided in packages... -.-

It is currently dormant; I had finished the looping logic, if memory serves well.

Michael.

Reply by email

silvioprog
to Michael Van Canneyt: This cannot be fixed. Lazreport is not suitable for use in webapplications. Some time…

2013/1/17 Michael Van Canneyt

Show quoted text 16 lines
On Wed, 16 Jan 2013, silvioprog wrote: Hello, > Please see in: > > http://bugs.freepascal.org/**view.php?id=23664<http://bugs.freepascal.org/view.php?id=23664> > This cannot be fixed. Lazreport is not suitable for use in webapplications. Some time ago, I started a new reporting engine exactly for this reason. A well-designed reporting engine is independent of any widget set. (see e.g. jasperreports in Java) Michael.

Hm... I'll close the issue. Thank you Michael.

Your report library will be open source? If yes, I would like to collaborate on the development. :)

I've been thinking of creating a library for reports based on JSON, but to create something like this would take too much time.

Silvio Cl?cio My public projects - github.com/silvioprog -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130117/f80f89d9/attachment.html>

Reply by email

silvioprog
to Sven Barth: And how far is your progress with that? Which reminds me that I should finally test the…

2013/1/17 Sven Barth

Show quoted text 8 lines
Am 17.01.2013 08:52, schrieb Michael Van Canneyt: A well-designed reporting engine is independent of any widget set. > (see e.g. jasperreports in Java) > Fully agreed here. :)

+1. :)

Regards, Sven
Silvio Cl?cio My public projects - github.com/silvioprog -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130117/51370ea4/attachment.html>

Reply by email

Michael Van Canneyt
to silvioprog: 2013/1/17 Michael Van Canneyt Hm... I'll close the issue. Thank you Michael. Your report…
silvioprog wrote 22 lines
2013/1/17 Michael Van Canneyt On Wed, 16 Jan 2013, silvioprog wrote: Hello, Please see in: http://bugs.freepascal.org/view.php?id=23664 This cannot be fixed. Lazreport is not suitable for use in webapplications. Some time ago, I started a new reporting engine exactly for this reason. A well-designed reporting engine is independent of any widget set. (see e.g. jasperreports in Java) Michael. Hm... I'll close the issue. Thank you Michael. Your report library will be open source??If yes, I would like to collaborate on the development. :)

It will be open source.

I've been thinking of creating a library for reports based on JSON, but to create something like this would take too much time.

The storage format is not really the problem.
The looping logic is far more difficult :(

Michael.

Reply by email

silvioprog
to Michael Van Canneyt: It is currently dormant; I had finished the looping logic, if memory serves well. Michael.

2013/1/17 Michael Van Canneyt

Show quoted text 14 lines
On Thu, 17 Jan 2013, Sven Barth wrote: Am 17.01.2013 08:52, schrieb Michael Van Canneyt: > >> Some time ago, I started a new reporting engine exactly for this reason. >> >> And how far is your progress with that? Which reminds me that I should > finally test the new database search provided in packages... -.- > It is currently dormant; I had finished the looping logic, if memory serves well. Michael.

I've been thinking of porting jsPDF for Free Pascal:

http://jspdf.com

But, using inheritance, something like (a pseudo example):

VLabel.Text := 'Hello';
VLabel.Font.Style := [fsBold];
VMemo.Lines.Add('Line 1');
VMemo.Lines.Add('Line 2');
VMemo.Font.Align := faJustify;
...
pdf.LoadFromJSON(<JSON>); // or pdf.LoadFromDataSet
pdf.AutoPaginate := True;
pdf.AddPage;
pdf.AddObject(VLabel);
pdf.AddObject(VMemo);
pdf.AddObject(VImage);
pdf.Print('print.pdf'); // or pdf.Print to print as DataURI
Silvio Cl?cio My public projects - github.com/silvioprog -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130117/9d9b2e39/attachment.html>

Reply by email

silvioprog
to Michael Van Canneyt: It will be open source. The storage format is not really the problem. The looping logic…

2013/1/17 Michael Van Canneyt

Show quoted text 29 lines
On Thu, 17 Jan 2013, silvioprog wrote: > 2013/1/17 Michael Van Canneyt > On Wed, 16 Jan 2013, silvioprog wrote: > > Hello, > Please see in: > > http://bugs.freepascal.org/**view.php?id=23664<http://bugs.freepascal.org/view.php?id=23664> > > > This cannot be fixed. Lazreport is not suitable for use in > webapplications. > > Some time ago, I started a new reporting engine exactly for this reason. > > A well-designed reporting engine is independent of any widget set. > (see e.g. jasperreports in Java) > > Michael. > > > Hm... I'll close the issue. Thank you Michael. > > Your report library will be open source? If yes, I would like to > collaborate on the development. :) > It will be open source.

Yeah! \o/

Show quoted text 8 lines
I've been thinking of creating a library for reports based on JSON, but > to create something like this would take too much time. > The storage format is not really the problem. The looping logic is far more difficult :( Michael.

Hm... The code is in a repository? Could create a temporary repository on Github, after done, move it to the Free Pascal SVN.

Silvio Cl?cio My public projects - github.com/silvioprog -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130117/a4055ada/attachment.html>

Reply by email

Michael Van Canneyt
to silvioprog: 2013/1/17 Michael Van Canneyt I've been thinking of porting jsPDF for Free Pascal:…
silvioprog wrote 17 lines
2013/1/17 Michael Van Canneyt On Thu, 17 Jan 2013, Sven Barth wrote: Am 17.01.2013 08:52, schrieb Michael Van Canneyt: Some time ago, I started a new reporting engine exactly for this reason. And how far is your progress with that? Which reminds me that I should finally test the new database search provided in packages... -.- It is currently dormant; I had finished the looping logic, if memory serves well. Michael. I've been thinking of porting jsPDF for Free Pascal: http://jspdf.com

Before you code anything that already exists, look at: https://github.com/jepafi

It's more promising. All it misses is embedding fonts, and that should be easily added.

Michael.

Reply by email

Leonardo M. Ramé
to Michael Van Canneyt: This cannot be fixed. Lazreport is not suitable for use in webapplications. Some time…
Michael Van Canneyt wrote 18 lines
On Wed, 16 Jan 2013, silvioprog wrote: >Hello, >Please see in: > >http://bugs.freepascal.org/view.php?id=23664 This cannot be fixed. Lazreport is not suitable for use in webapplications. Some time ago, I started a new reporting engine exactly for this reason. A well-designed reporting engine is independent of any widget set. (see e.g. jasperreports in Java) Michael.

I had a similar issue some time ago with, TAChart. It needed TCanvas to draw charts, but that was fixed by Alexander, if I remember correctly.

That's why I stopped looking for a report generator for my cgi apps. Now I rely on libHaru (http://libharu.org/), which is a C shared library with Pascal bindings that allows creation of PDF files.

The problem with libHaru is you don't create reports out of markup, but by code. In my case that's not a problem, because I'm the only one in charge of creating reports, a different story will be when the final user wants to create their own reports.

Reply by email

Leonardo M. Ramé
to silvioprog: 2013/1/17 Michael Van Canneyt I've been thinking of porting jsPDF for Free Pascal:…
silvioprog wrote 37 lines
2013/1/17 Michael Van Canneyt <[1]> On Thu, 17 Jan 2013, Sven Barth wrote: Am 17.01.2013 08:52, schrieb Michael Van Canneyt: Some time ago, I started a new reporting engine exactly for this reason. And how far is your progress with that? Which reminds me that I should finally test the new database search provided in packages... -.- It is currently dormant; I had finished the looping logic, if memory serves well. Michael. I've been thinking of porting jsPDF for Free Pascal: [2]http://jspdf.com But, using inheritance, something like (a pseudo example): VLabel.Text := 'Hello'; VLabel.Font.Style := [fsBold]; VMemo.Lines.Add('Line 1'); VMemo.Lines.Add('Line 2'); VMemo.Font.Align := faJustify; ... pdf.LoadFromJSON(<JSON>); // or?pdf.LoadFromDataSet pdf.AutoPaginate := True; pdf.AddPage; pdf.AddObject(VLabel); pdf.AddObject(VMemo); pdf.AddObject(VImage); pdf.Print('print.pdf'); // or pdf.Print to print as DataURI -- Silvio Cl?cio My public projects - [3]github.com/silvioprog

libHaru is exactly that, and I can confirm it works with Unicode Fonts, and everything I need.

Reply by email

silvioprog
to Michael Van Canneyt: Before you code anything that already exists, look at: https://github.com/jepafi It's…

2013/1/17 Michael Van Canneyt

Show quoted text 33 lines
On Thu, 17 Jan 2013, silvioprog wrote: > 2013/1/17 Michael Van Canneyt > On Thu, 17 Jan 2013, Sven Barth wrote: > > Am 17.01.2013 08:52, schrieb Michael Van Canneyt: > Some time ago, I started a new reporting engine exactly > for this reason. > > And how far is your progress with that? Which reminds me that > I should finally test the new database search provided in packages... -.- > > > It is currently dormant; I had finished the looping logic, if memory > serves well. > > Michael. > > > I've been thinking of porting jsPDF for Free Pascal: > > http://jspdf.com > Before you code anything that already exists, look at: https://github.com/jepafi It's more promising. All it misses is embedding fonts, and that should be easily added. Michael.

Yes, it's promising, but I would do something a bit more object-oriented, and less like PHP. :)

And yet I've been thinking in the following:

pdf.Filter(T<ProjectCodeName>PDFFilter);
pdf.Save('print.pdf');

or ...

pdf.Filter(T<ProjectCodeName>XLSFilter);
pdf.Save('print.xls');

And also would a design report (as IDE).

Silvio Cl?cio My public projects - github.com/silvioprog -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130117/f8fb412b/attachment.html>

Reply by email

silvioprog
to Leonardo M. Ramé: I had a similar issue some time ago with, TAChart. It needed TCanvas to draw charts, but…

2013/1/17 Leonardo M. Ram?

Show quoted text 35 lines
On 2013-01-17 08:52:11 +0100, Michael Van Canneyt wrote: > > On Wed, 16 Jan 2013, silvioprog wrote: > > >Hello, > >Please see in: > > > >http://bugs.freepascal.org/view.php?id=23664 > > This cannot be fixed. Lazreport is not suitable for use in webapplications. > > Some time ago, I started a new reporting engine exactly for this reason. > > A well-designed reporting engine is independent of any widget set. > (see e.g. jasperreports in Java) > > Michael. > I had a similar issue some time ago with, TAChart. It needed TCanvas to draw charts, but that was fixed by Alexander, if I remember correctly. That's why I stopped looking for a report generator for my cgi apps. Now I rely on libHaru (http://libharu.org/), which is a C shared library with Pascal bindings that allows creation of PDF files. The problem with libHaru is you don't create reports out of markup, but by code. In my case that's not a problem, because I'm the only one in charge of creating reports, a different story will be when the final user wants to create their own reports. -- Leonardo M. Ram? http://leonardorame.blogspot.com

Very nice.

You could send a small example with this library to take a look? Thank you.

Silvio Cl?cio My public projects - github.com/silvioprog -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130117/52012e0e/attachment.html>

Reply by email

silvioprog
to Leonardo M. Ramé: libHaru is exactly that, and I can confirm it works with Unicode Fonts, and everything I…

2013/1/17 Leonardo M. Ram?

Show quoted text 47 lines
On 2013-01-17 08:52:49 -0200, silvioprog wrote: > 2013/1/17 Michael Van Canneyt <[1]> > > On Thu, 17 Jan 2013, Sven Barth wrote: > > Am 17.01.2013 08:52, schrieb Michael Van Canneyt: > > Some time ago, I started a new reporting engine exactly for this > reason. > > And how far is your progress with that? Which reminds me that I should > finally test the new database search provided in packages... -.- > > It is currently dormant; I had finished the looping logic, if memory > serves well. > > Michael. > > I've been thinking of porting jsPDF for Free Pascal: > [2]http://jspdf.com > But, using inheritance, something like (a pseudo example): > VLabel.Text := 'Hello'; > VLabel.Font.Style := [fsBold]; > VMemo.Lines.Add('Line 1'); > VMemo.Lines.Add('Line 2'); > VMemo.Font.Align := faJustify; > ... > pdf.LoadFromJSON(<JSON>); // or pdf.LoadFromDataSet > pdf.AutoPaginate := True; > pdf.AddPage; > pdf.AddObject(VLabel); > pdf.AddObject(VMemo); > pdf.AddObject(VImage); > pdf.Print('print.pdf'); // or pdf.Print to print as DataURI > -- > Silvio Cl?cio > My public projects - [3]github.com/silvioprog > libHaru is exactly that, and I can confirm it works with Unicode Fonts, and everything I need. -- Leonardo M. Ram? http://leonardorame.blogspot.com

Yes. I also need full support for UTF8.

Silvio Cl?cio My public projects - github.com/silvioprog -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130117/572b82b8/attachment.html>

Reply by email

Leonardo M. Ramé
to silvioprog: 2013/1/17 Leonardo M. Ram? Very nice. You could send a small example with this library to…
silvioprog wrote 42 lines
2013/1/17 Leonardo M. Ram? <[1]> On 2013-01-17 08:52:11 +0100, Michael Van Canneyt wrote: > > On Wed, 16 Jan 2013, silvioprog wrote: > > >Hello, > >Please see in: > > > >[2]http://bugs.freepascal.org/view.php?id=23664 > > This cannot be fixed. Lazreport is not suitable for use in webapplications. > > Some time ago, I started a new reporting engine exactly for this reason. > > A well-designed reporting engine is independent of any widget set. > (see e.g. jasperreports in Java) > > Michael. > I had a similar issue some time ago with, TAChart. It needed TCanvas to draw charts, but that was fixed by Alexander, if I remember correctly. That's why I stopped looking for a report generator for my cgi apps. Now I rely on libHaru ([3]http://libharu.org/), which is a C shared library with Pascal bindings that allows creation of PDF files. The problem with libHaru is you don't create reports out of markup, but by code. In my case that's not a problem, because I'm the only one in charge of creating reports, a different story will be when the final user wants to create their own reports. -- Leonardo M. Ram? [4]http://leonardorame.blogspot.com Very nice. You could send a small example with this library to take a look? Thank you. --

Yes, te attached file generates a report based on a TCollection containing the data for each page, it has a header, body (with many lines) and a footer. I also attached a small jpg showing the final report.

Leonardo M. Ram? http://leonardorame.blogspot.com -------------- next part -------------- unit resumen_cuenta; {$mode delphi}{$H+} interface uses SysUtils, hpdf, hpdf_types, hpdf_consts, Math, Classes, datos_resumen; type { TResumenCta } TResumenCta = class(TCollectionItem) private FDatosResumen: TDatosResumen; page: HPDF_Page; pageWidth: Double; pageHeight: Double; leftMargin: Double; rightMargin: Double; topMargin: Double; x: double; y: double; angle1: double; rad1: double; image: HPDF_Image; iw: double; ih: double; pdf: HPDF_Doc; FFont: HPDF_Font; FBold: HPDF_Font; FBolditalic: HPDF_Font; FLogoGS: HPDF_Image; FLogoBW: HPDF_Image; procedure WriteText(page: HPDF_Page; x,y: double; Text: string; font: HPDF_Font); procedure WriteCenteredText(page: HPDF_Page; x,w,y: double; Text: string; font: HPDF_Font); procedure WriteRightAlignedText(page: HPDF_Page; x,w,y: double; Text: string; font: HPDF_Font); procedure DrawCoupon(page: HPDF_Page; x, y: double; font, bold: HPDF_Font; pdf: HPDF_Doc); procedure ImprimirDetalle(font, bold: HPDF_Font); public constructor Create(ACollection: TCollection); override; procedure Draw; property bold: HPDF_Font read FBold write FBold; property font: HPDF_Font read FFont write FFont; property boldItalic: HPDF_Font read FBoldItalic write FBoldItalic; property DatosResumen: TDatosResumen read FDatosResumen write FDatosResumen; property LogoGS: HPDF_Image read FLogoGS write FLogoGS; property LogoBW: HPDF_Image read FLogoBW write FLogoBW; end; { TResumenesCta } TResumenesCta = class(TCollection) private FDatosResumenes: TDatosResumenes; FPdf: HPDF_Doc; font: HPDF_Font; bold: HPDF_Font; bolditalic: HPDF_Font; FLogoGS: HPDF_Image; FLogoBW: HPDF_Image; function GetItem(AIndex: Integer): TResumenCta; public constructor Create(ADatosResumenes: TDatosResumenes); destructor Destroy; override; function Add: TResumenCta; procedure Save; procedure SaveToStream(AStream: TStream); procedure Draw; property Items[AIndex: Integer]: TResumenCta read GetItem; default; property pdf: HPDF_Doc read FPdf; property DatosResumenes: TDatosResumenes read FDatosResumenes; end; implementation const cLineHeight = 12; fname: string = 'Test.pdf'; DASH_MODE1: array[0..0] of HPDF_UINT16 = (5); procedure error_handler (error_no: HPDF_STATUS; detail_no: HPDF_STATUS; user_data: Pointer); stdcall; var message: string; begin message := 'ERROR: ' + IntToStr(error_no) + '-' + IntToStr(detail_no); raise Exception.Create(message); end; { TResumenesCta } constructor TResumenesCta.Create(ADatosResumenes: TDatosResumenes); begin inherited Create(TResumenCta); Fpdf := HPDF_New(@error_handler, nil); HPDF_SetCompressionMode(Fpdf, HPDF_COMP_ALL); {* create default-font *} bold := HPDF_GetFont(Fpdf, 'Courier-Bold', 'WinAnsiEncoding'); font := HPDF_GetFont(Fpdf, 'Courier', 'WinAnsiEncoding'); bolditalic := HPDF_GetFont(Fpdf, 'Courier-BoldOblique', 'WinAnsiEncoding'); FDatosResumenes := ADatosResumenes; if not fileExists('logo-gs.png') then raise Exception.Create('file logo-gs.png does not exists.'); FLogoGS := HPDF_LoadPngImageFromFile (pdf, 'logo-gs.png'); if not fileExists('logo-bw.png') then raise Exception.Create('file logo-bw.png does not exists.'); FLogoBW := HPDF_LoadPngImageFromFile (pdf, 'logo-bw.png'); end; destructor TResumenesCta.Destroy; begin HPDF_Free (pdf); end; function TResumenesCta.Add: TResumenCta; begin Result := TResumenCta(inherited Add); Result.pdf := FPdf; Result.font := font; Result.bold := bold; Result.boldItalic:= bolditalic; end; procedure TResumenesCta.Save; begin (* save the document to a file *) HPDF_SaveToFile (Fpdf, PChar(fname)); end; procedure TResumenesCta.SaveToStream(AStream: TStream); var lSize: HPDF_UINT32; buf: array[0..4096] of HPDF_BYTE; begin HPDF_SaveToStream(pdf); HPDF_ResetStream(pdf); while true do begin lSize := 4096; HPDF_ReadFromStream(pdf, buf, @lSize); if(lSize = 0) then break; AStream.Write(buf, lSize); end; AStream.Position := 0; end; procedure TResumenesCta.Draw; var I: Integer; lResumenCta: TResumenCta; begin Clear; for I := 0 to FDatosResumenes.Count - 1 do begin lResumenCta := Add; lResumenCta.LogoBW:= FLogoBW; lResumenCta.LogoGS:= FLogoGS; lResumenCta.DatosResumen := FDatosResumenes[I]; lResumenCta.Draw; end; end; function TResumenesCta.GetItem(AIndex: Integer): TResumenCta; begin Result := TResumenCta(inherited GetItem(AIndex)); end; { TResumenCta } constructor TResumenCta.Create(ACollection: TCollection); begin page := HPDF_AddPage((ACollection as TResumenesCta).pdf); (* tama?o de p?gina *) pageWidth := HPDF_Page_GetWidth(page); pageHeight := HPDF_Page_GetHeight(page); leftMargin := 10; rightMargin := pageWidth - leftMargin; topMargin := pageHeight - 10; x := leftMargin + 4; y := topMargin; end; procedure TResumenCta.WriteText(page: HPDF_Page; x,y: double; Text: string; font: HPDF_Font); begin HPDF_Page_BeginText(page); HPDF_Page_MoveTextPos(page, x, y); HPDF_Page_SetFontAndSize(page, font, 10); HPDF_Page_ShowText(page, PAnsiChar(UTF8ToAnsi(Text))); HPDF_Page_EndText(page); end; procedure TResumenCta.WriteCenteredText(page: HPDF_Page; x,w,y: double; Text: string; font: HPDF_Font); var lText: PAnsiChar; begin lText := PAnsiChar(UTF8ToAnsi(Text)); HPDF_Page_BeginText(page); HPDF_Page_MoveTextPos(page, x, y); HPDF_Page_SetFontAndSize(page, font, 10); HPDF_Page_TextRect(page, x, y, x + w, y, lText, HPDF_TALIGN_CENTER, nil); HPDF_Page_EndText(page); end; procedure TResumenCta.WriteRightAlignedText(page: HPDF_Page; x,w,y: double; Text: string; font: HPDF_Font); var lText: PAnsiChar; begin lText := PAnsiChar(UTF8ToAnsi(Text)); HPDF_Page_BeginText(page); HPDF_Page_MoveTextPos(page, x, y); HPDF_Page_SetFontAndSize(page, font, 10); HPDF_Page_TextRect(page, x, y, x + w, y, lText, HPDF_TALIGN_RIGHT, nil); HPDF_Page_EndText(page); end; procedure TResumenCta.DrawCoupon(page: HPDF_Page; x, y: double; font, bold: HPDF_Font; pdf: HPDF_Doc); var image: HPDF_Image; iw: double; ih: double; begin iw := HPDF_Image_GetWidth(FLogoBW) / 6; ih := HPDF_Image_GetHeight(FLogoBW) / 6; HPDF_Page_DrawImage(page, FLogoBW, x + 43, y, iw, ih); y := y - (cLineHeight * 0.5); WriteCenteredText(page, x, 210, y, 'Vencimiento', font); y := y - cLineHeight; WriteCenteredText(page, x, 210, y, FormatDateTime('DD/MM/YYYY', FDatosResumen.Vto), font); y := y - (cLineHeight * 1.5); WriteCenteredText(page, x, 210, y, FDatosResumen.Cliente, bold); y := y - cLineHeight; WriteCenteredText(page, x, 210, y, 'Cta. N? ' + FDatosResumen.TarjetaNro, bold); y := y - (cLineHeight * 1.5); WriteCenteredText(page, x, 210, y, 'Importe: $ ' + Format('%.2f', [FDatosResumen.Importe]), font); y := y - cLineHeight; WriteCenteredText(page, x, 210, y, Format('N? Resumen: %d', [FDatosResumen.ResumenNro]), font); end; function compare(Item1, Item2: TCollectionItem): Integer; var lItem1: TItemDetalle; lItem2: TItemDetalle; begin lItem1 := Item1 as TItemDetalle; lItem2 := Item2 as TItemDetalle; if lItem1.Tipo < lItem2.Tipo then Result := -1 else if lItem1.Tipo > lItem2.Tipo then Result := 1 else Result := 0; end; procedure TResumenCta.ImprimirDetalle(font, bold: HPDF_Font); var I: Integer; y: Integer; lDetalle: TItemDetalle; lFont: HPDF_Font; lTipo: Integer; begin y := 694; x := leftMargin + 5; lTipo := 1; // el tipo 1 no se muestra, para mostrarlo comenzar con tipo -1. //FDatosResumen.Detalle.Sort(compare); for I := 0 to FDatosResumen.Detalle.Count - 1 do begin lDetalle := FDatosResumen.Detalle[I]; if lDetalle.Tipo lTipo then begin lTipo := lDetalle.Tipo; lFont := bold; lDetalle := FDatosResumen.Detalle[I]; case lTipo of 2: WriteText(page, x + 120, y, 'CONSUMO DEL MES', lFont); 3: WriteText(page, x + 120, y, 'CONSUMO DE LOS ADICIONALES', lFont); 4: WriteText(page, x + 120, y, 'CARGOS FIJOS', lFont); 5: WriteText(page, x + 120, y, 'OTROS CARGOS (5)', lFont); 7: WriteText(page, x + 120, y, 'OTROS CARGOS', lFont); else WriteText(page, x + 120, y, Format('Tipo: %d', [lTipo]), lFont); end; y := y - cLineHeight; end; lFont := font; WriteText(page, x, y, FormatDateTime('DD/MM/YYYY', lDetalle.Fecha), lFont); WriteRightAlignedText(page, x + 60, 50, (y - 4) + cLineHeight, lDetalle.Cupon, lFont); WriteText(page, x + 120, y, lDetalle.Concepto, lFont); WriteRightAlignedText(page, x + 495, 70, (y - 4) + cLineHeight, Format('$ %.2f', [lDetalle.Importe]), lFont); y := y - cLineHeight; end; end; procedure TResumenCta.Draw; begin {* encabezado *} HPDF_Page_SetGrayFill (page, 0.8); HPDF_Page_Rectangle(page, leftMargin, topMargin, rightMargin - leftMargin, -54); HPDF_Page_Fill(page); HPDF_Page_SetGrayFill (page, 0); HPDF_Page_SetFontAndSize(page, bold, 10); y := y - cLineHeight; WriteText(page, x, y, 'Se?ores', bold); y := y - cLineHeight; WriteText(page, x, y, FDatosResumen.Cliente, bold); y := y - cLineHeight; WriteText(page, x, y, FDatosResumen.GetDomicilio, bold); y := y - cLineHeight; WriteText(page, x, y, FDatosResumen.GetBarrio, bold); HPDF_Page_SetLineWidth (page, 0.5); HPDF_Page_SetGrayFill (page, 1); HPDF_Page_SetGrayStroke(page, 0); HPDF_Page_Rectangle(page, 360, topMargin - 2, 110, -50); HPDF_Page_Rectangle(page, 473, topMargin - 2, 110, -50); HPDF_Page_FillStroke(page); DefaultFormatSettings.DateSeparator := '/'; HPDF_Page_SetGrayFill (page, 0); y := topMargin - 4; x := 360; WriteCenteredText(page, x, 110, y, 'Per?odo desde', bold); y := y - cLineHeight; WriteCenteredText(page, x, 110, y, FormatDateTime('DD/MM/YYYY', FDatosResumen.Desde), font); y := y - cLineHeight; WriteCenteredText(page, x, 110, y, 'Per?odo hasta', bold); y := y - cLineHeight; WriteCenteredText(page, x, 110, y, FormatDateTime('DD/MM/YYYY', FDatosResumen.Hasta), font); y := topMargin - 4; x := 473; WriteCenteredText(page, x, 110, y, 'Fecha emisi?n', bold); y := y - cLineHeight; WriteCenteredText(page, x, 110, y, FormatDateTime('DD/MM/YYYY', FDatosResumen.Emision), font); y := y - cLineHeight; WriteCenteredText(page, x, 110, y, 'Fecha vto.', bold); y := y - cLineHeight; WriteCenteredText(page, x, 110, y, FormatDateTime('DD/MM/YYYY', FDatosResumen.Vto), font); x := leftMargin; y := (y + 4) - (cLineHeight * 2.5); WriteText(page, x, y, 'CUIL / CUIT: ' + FDatosResumen.CUIL + ' ' + FDatosResumen.CondIVA + ' PESOS (Arg.)', bold); y := y - cLineHeight; WriteText(page, x, y, 'Tarjeta Nro.: ' + FDatosResumen.TarjetaNro + ' - Alta/Renovaci?n: ' + FormatDateTime('DD/MM/YYYY', FDatosResumen.Renovacion), bold); y := y - cLineHeight; (* Tabla *) // borde general HPDF_Page_SetLineWidth (page, 0.5); HPDF_Page_SetGrayFill (page, 1); HPDF_Page_SetGrayStroke(page, 0); HPDF_Page_Rectangle(page, leftMargin, y, pageWidth - (leftMargin * 2), -550); HPDF_Page_FillStroke(page); // primera linea HPDF_Page_SetLineWidth (page, 0.5); HPDF_Page_SetGrayFill (page, 0.75); HPDF_Page_SetGrayStroke(page, 0); HPDF_Page_Rectangle(page, leftMargin, y, pageWidth - (leftMargin * 2), -(cLineHeight + 5)); HPDF_Page_FillStroke(page); HPDF_Page_SetGrayFill (page, 0); WriteCenteredText(page, x, pageWidth, y - 3, 'DETALLE RESUMEN DE CUENTA', bold); // segunda linea y := y - (cLineHeight + 5); HPDF_Page_SetLineWidth (page, 0.5); HPDF_Page_SetGrayFill (page, 1); HPDF_Page_SetGrayStroke(page, 0); HPDF_Page_Rectangle(page, leftMargin, y, pageWidth - (leftMargin * 2), -(cLineHeight + 5)); HPDF_Page_FillStroke(page); HPDF_Page_SetGrayFill (page, 0); y := y - 3; WriteCenteredText(page, x, 70, y, 'FECHA', font); WriteCenteredText(page, x + 70, 50, y, 'CUPON', font); WriteCenteredText(page, x + 130, 380, y, 'CONCEPTO', font); WriteCenteredText(page, x + 498, 80, y, 'IMPORTE', font); // divisores de columna linea continua y := y - cLineHeight; HPDF_Page_SetLineWidth (page, 0.5); HPDF_Page_SetGrayFill (page, 1); HPDF_Page_SetGrayStroke(page, 0); x := 80; HPDF_Page_MoveTo(page, x, 724); HPDF_Page_LineTo(page, x, 707); x := 130; HPDF_Page_MoveTo(page, x, 724); HPDF_Page_LineTo(page, x, 707); x := 510; HPDF_Page_MoveTo(page, x, 724); HPDF_Page_LineTo(page, x, 707); HPDF_Page_FillStroke(page); (* Se incluye filigrama *) iw := HPDF_Image_GetWidth(FLogoGS) / 2.5; ih := HPDF_Image_GetHeight(FLogoGS) / 2.5; x := (pageWidth / 2) - (iw / 2); y := (pageHeight / 2); HPDF_Page_DrawImage(page, FLogoGS, x, y, iw, ih); // divisores de columna linea discontinua y := y - cLineHeight; HPDF_Page_SetLineWidth (page, 0.5); HPDF_Page_SetGrayFill (page, 1); HPDF_Page_SetGrayStroke(page, 0.75); HPDF_Page_SetDash(page, @DASH_MODE1, 1, 1); x := 80; HPDF_Page_MoveTo(page, x, 704); HPDF_Page_LineTo(page, x, 200); x := 130; HPDF_Page_MoveTo(page, x, 704); HPDF_Page_LineTo(page, x, 200); x := 510; HPDF_Page_MoveTo(page, x, 704); HPDF_Page_LineTo(page, x, 200); HPDF_Page_FillStroke(page); // pie de la tabla y := 200; HPDF_Page_SetLineWidth (page, 0.5); HPDF_Page_SetGrayFill (page, 1); HPDF_Page_SetGrayStroke(page, 0); HPDF_Page_SetDash(page, nil, 0, 0); HPDF_Page_Rectangle(page, leftMargin, y, pageWidth - (leftMargin * 2), -(cLineHeight + 5)); HPDF_Page_FillStroke(page); x := 510; HPDF_Page_SetLineWidth (page, 0.5); HPDF_Page_SetGrayFill (page, 0.75); HPDF_Page_SetGrayStroke(page, 0); HPDF_Page_SetDash(page, nil, 0, 0); HPDF_Page_Rectangle(page, x, y, 75, -(cLineHeight + 5)); HPDF_Page_FillStroke(page); x := 350; HPDF_Page_SetGrayFill (page, 0); y := y - 3; WriteRightAlignedText(page, x, 150, y, 'Saldo al ' + FormatDateTime('DD/MM/YYYY', FDatosResumen.Desde), FBold); HPDF_Page_SetGrayFill (page, 0); x := 510; WriteRightAlignedText(page, x, 70, y, '$ ' + Format('%.2f', [FDatosResumen.Importe]), FBold); (* Recuadro lugares de pago *) y := y - 28; HPDF_Page_SetLineWidth (page, 0.5); HPDF_Page_SetGrayFill (page, 0); HPDF_Page_SetGrayStroke(page, 0); HPDF_Page_Rectangle(page, leftMargin + 8, y, pageWidth - ((leftMargin + 5) * 2), -(cLineHeight + 5)); HPDF_Page_FillStroke(page); y := y + 3; HPDF_Page_SetLineWidth (page, 0.5); HPDF_Page_SetGrayFill (page, 1); HPDF_Page_SetGrayStroke(page, 0); HPDF_Page_Rectangle(page, leftMargin + 5, y, pageWidth - ((leftMargin + 5) * 2), -(cLineHeight + 5)); HPDF_Page_FillStroke(page); HPDF_Page_SetGrayFill (page, 0); x := leftMargin + 5; y := y - 2; WriteCenteredText(page, x, pageWidth - ((leftMargin + 5) * 2), y - 1, 'Este resumen podr? ser abonado en Farmacias Del Milagro y Del Norte, o por D?bito Autom?tico', FBolditalic); (* linea discontinua horizontal*) y := y - 30; HPDF_Page_SetLineWidth (page, 0.5); HPDF_Page_SetGrayFill (page, 1); HPDF_Page_SetGrayStroke(page, 0.75); HPDF_Page_SetDash(page, @DASH_MODE1, 1, 1); x := leftMargin; HPDF_Page_MoveTo(page, x, y); HPDF_Page_LineTo(page, x + (pageWidth - (leftMargin * 2)), y); (* 1ra linea discontinua vertical *) x := (leftMargin + (pageWidth - (leftMargin * 2))) / 3; HPDF_Page_MoveTo(page, x, y); HPDF_Page_LineTo(page, x, y - 140); (* 2da linea discontinua vertical *) x := x + ((leftMargin + (pageWidth - (leftMargin * 2))) / 3); HPDF_Page_MoveTo(page, x, y); HPDF_Page_LineTo(page, x, y - 140); HPDF_Page_FillStroke(page); (* Pi? *) angle1 := 90; HPDF_Page_SetFontAndSize(page, font, 10); rad1 := DegToRad(angle1); HPDF_Page_SetGrayFill (page, 0); HPDF_Page_BeginText (page); HPDF_Page_SetTextMatrix (page, cos(rad1), sin(rad1), -sin(rad1), cos(rad1), leftMargin + 5, y - 94); HPDF_Page_ShowText (page, 'Para el cliente'); x := (leftMargin + (pageWidth - (leftMargin * 2))) / 3; HPDF_Page_SetTextMatrix (page, cos(rad1), sin(rad1), -sin(rad1), cos(rad1), x + 10, y - 82); HPDF_Page_ShowText (page, 'Para el banco'); x := x + (leftMargin + (pageWidth - (leftMargin * 2))) / 3; HPDF_Page_SetTextMatrix (page, cos(rad1), sin(rad1), -sin(rad1), cos(rad1), x + 10, y - 112); HPDF_Page_ShowText (page, 'Para Tarjeta Salud'); HPDF_Page_EndText (page); HPDF_Page_SetGrayFill (page, 0); x := leftMargin; y := y - (cLineHeight * 3); DrawCoupon(page, x, y, font, bold, pdf); x := (leftMargin + (pageWidth - (leftMargin * 2))) / 3; DrawCoupon(page, x, y, font, bold, pdf); x := x + (leftMargin + (pageWidth - (leftMargin * 2))) / 3; DrawCoupon(page, x, y, font, bold, pdf); (* Detalle *) HPDF_Page_SetGrayFill (page, 0); ImprimirDetalle(font, bold); end; end. -------------- next part -------------- A non-text attachment was scrubbed... Name: report.jpg Type: image/jpeg Size: 30006 bytes Desc: not available URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130117/d0d98709/attachment-0001.jpg>

Reply by email

Graeme Geldenhuys
to silvioprog: 2013/1/17 Michael Van Canneyt I've been thinking of porting jsPDF for Free Pascal:…
silvioprog wrote
I've been thinking of porting jsPDF for Free Pascal:

fpGUI also has a small PDF reporting engine. To see what it can do, take a look at the demo in <fpgui>\examples\gui\reporting

Some features:
* Text output (obviously)
* Text attributes (color, size, font, alignment etc)
* Image support
* Drawing primitives
* Headers, Footers
* Sections
* Grids
* Page numbers, Section numbers
* Page attributes (landscape, portrait, mixed, pages sizes etc)
* PDF attributes (eg: when file is opened go full screen or 2-up etc)
* Print Preview (this is dependent on fpGUI of course, but it is a separate unit, so isn't a problem)

It doesn't bind to datasets etc. You simply iterate whatever data you want, and write whatever to the PDF's canvas. This gives you the most flexibility and allows creating reports from anything (business objects, datasets, stringgrid etc).

Currently the PDF engine has very little dependency on fpGUI - a data type which could be easily redefined in the reporting unit itself, and some color utility methods, which again could be redefined in the reporting units themselves.

I'm using this PDF engine to generate rather complex reports in our commercial apps, reporting from tiOPF-based business objects. It works very well.

An French developer wrote and contributed this to the fpGUI project. Some classes and methods are still in French though, but if you look at the demo project and its demo reports, it is easy to figure out. We are still working on translating everything to English. If you do try it out and hit a problem, you are welcome to post questions in the fpgui.support newsgroup (see the website for details).

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 42 lines
On 01/17/13 10:52, silvioprog wrote: > > I've been thinking of porting jsPDF for Free Pascal: fpGUI also has a small PDF reporting engine. To see what it can do, take a look at the demo in <fpgui>\examples\gui\reporting Some features: * Text output (obviously) * Text attributes (color, size, font, alignment etc) * Image support * Drawing primitives * Headers, Footers * Sections * Grids * Page numbers, Section numbers * Page attributes (landscape, portrait, mixed, pages sizes etc) * PDF attributes (eg: when file is opened go full screen or 2-up etc) * Print Preview (this is dependent on fpGUI of course, but it is a separate unit, so isn't a problem) It doesn't bind to datasets etc. You simply iterate whatever data you want, and write whatever to the PDF's canvas. This gives you the most flexibility and allows creating reports from anything (business objects, datasets, stringgrid etc). Currently the PDF engine has very little dependency on fpGUI - a data type which could be easily redefined in the reporting unit itself, and some color utility methods, which again could be redefined in the reporting units themselves. I'm using this PDF engine to generate rather complex reports in our commercial apps, reporting from tiOPF-based business objects. It works very well. An French developer wrote and contributed this to the fpGUI project. Some classes and methods are still in French though, but if you look at the demo project and its demo reports, it is easy to figure out. We are still working on translating everything to English. If you do try it out and hit a problem, you are welcome to post questions in the fpgui.support newsgroup (see the website for details).

Well, I was looking at this too for a PDF backend.

Finally, it was the dependency on fpGUI that stopped me from using it.

If we can make sure there is no such dependency,
I'd very much like to have it in FPC itself.

Michael.

Reply by email

Marcos Douglas
to silvioprog: 2013/1/17 Michael Van Canneyt I've been thinking of porting jsPDF for Free Pascal:…
silvioprog wrote 36 lines
2013/1/17 Michael Van Canneyt > > On Thu, 17 Jan 2013, Sven Barth wrote: > >> Am 17.01.2013 08:52, schrieb Michael Van Canneyt: >>> >>> Some time ago, I started a new reporting engine exactly for this reason. >>> >> And how far is your progress with that? Which reminds me that I should finally test the new database search provided in packages... -.- > > > It is currently dormant; I had finished the looping logic, if memory serves well. > > Michael. I've been thinking of porting jsPDF for Free Pascal: http://jspdf.com But, using inheritance, something like (a pseudo example): VLabel.Text := 'Hello'; VLabel.Font.Style := [fsBold]; VMemo.Lines.Add('Line 1'); VMemo.Lines.Add('Line 2'); VMemo.Font.Align := faJustify; ... pdf.LoadFromJSON(<JSON>); // or pdf.LoadFromDataSet pdf.AutoPaginate := True; pdf.AddPage; pdf.AddObject(VLabel); pdf.AddObject(VMemo); pdf.AddObject(VImage); pdf.Print('print.pdf'); // or pdf.Print to print as DataURI

Why jsPDF and no FPDF (https://github.com/jepafi/Free-JPDF-Pascal)?

Marcos Douglas
PS: or my fork https://github.com/mdbs99/Free-JPDF-Pascal

Reply by email

Michael Van Canneyt
to Marcos Douglas
Marcos Douglas wrote 42 lines
On Thu, Jan 17, 2013 at 7:52 AM, silvioprog wrote: > > 2013/1/17 Michael Van Canneyt >> >> On Thu, 17 Jan 2013, Sven Barth wrote: >> >>> Am 17.01.2013 08:52, schrieb Michael Van Canneyt: >>>> >>>> Some time ago, I started a new reporting engine exactly for this reason. >>>> >>> And how far is your progress with that? Which reminds me that I should finally test the new database search provided in packages... -.- >> >> >> It is currently dormant; I had finished the looping logic, if memory serves well. >> >> Michael. > > > I've been thinking of porting jsPDF for Free Pascal: > > http://jspdf.com > > But, using inheritance, something like (a pseudo example): > > VLabel.Text := 'Hello'; > VLabel.Font.Style := [fsBold]; > VMemo.Lines.Add('Line 1'); > VMemo.Lines.Add('Line 2'); > VMemo.Font.Align := faJustify; > ... > pdf.LoadFromJSON(<JSON>); // or pdf.LoadFromDataSet > pdf.AutoPaginate := True; > pdf.AddPage; > pdf.AddObject(VLabel); > pdf.AddObject(VMemo); > pdf.AddObject(VImage); > pdf.Print('print.pdf'); // or pdf.Print to print as DataURI Why jsPDF and no FPDF (https://github.com/jepafi/Free-JPDF-Pascal)? Marcos Douglas PS: or my fork https://github.com/mdbs99/Free-JPDF-Pascal

Why did you fork this ?

Michael.

Reply by email

Marcos Douglas
to Michael Van Canneyt: Before you code anything that already exists, look at: https://github.com/jepafi It's…
Michael Van Canneyt wrote 31 lines
On Thu, 17 Jan 2013, silvioprog wrote: > 2013/1/17 Michael Van Canneyt > On Thu, 17 Jan 2013, Sven Barth wrote: > > Am 17.01.2013 08:52, schrieb Michael Van Canneyt: > Some time ago, I started a new reporting engine exactly > for this reason. > > And how far is your progress with that? Which reminds me that > I should finally test the new database search provided in packages... -.- > > > It is currently dormant; I had finished the looping logic, if memory > serves well. > > Michael. > > > I've been thinking of porting jsPDF for Free Pascal: > > http://jspdf.com Before you code anything that already exists, look at: https://github.com/jepafi It's more promising. All it misses is embedding fonts, and that should be easily added.

Yes, I agree.
I have a fork here https://github.com/mdbs99/Free-JPDF-Pascal

Yes, I agree.
I have a fork here https://github.com/mdbs99/Free-JPDF-Pascal

Memleak and some minor fixes was done -- but not merged in the original project yet.
I want to codify a class more like FPDF (original PHP) to use the same documentations and another more "pascal-stylish".

https://github.com/mdbs99/Free-JPDF-Pascal

Marcos Douglas

Reply by email

silvioprog
to Marcos Douglas: Why jsPDF and no FPDF (https://github.com/jepafi/Free-JPDF-Pascal)? Marcos Douglas PS: or…

2013/1/17 Marcos Douglas

Show quoted text 45 lines
On Thu, Jan 17, 2013 at 7:52 AM, silvioprog wrote: > > 2013/1/17 Michael Van Canneyt >> >> On Thu, 17 Jan 2013, Sven Barth wrote: >> >>> Am 17.01.2013 08:52, schrieb Michael Van Canneyt: >>>> >>>> Some time ago, I started a new reporting engine exactly for this reason. >>>> >>> And how far is your progress with that? Which reminds me that I should finally test the new database search provided in packages... -.- >> >> >> It is currently dormant; I had finished the looping logic, if memory serves well. >> >> Michael. > > > I've been thinking of porting jsPDF for Free Pascal: > > http://jspdf.com > > But, using inheritance, something like (a pseudo example): > > VLabel.Text := 'Hello'; > VLabel.Font.Style := [fsBold]; > VMemo.Lines.Add('Line 1'); > VMemo.Lines.Add('Line 2'); > VMemo.Font.Align := faJustify; > ... > pdf.LoadFromJSON(<JSON>); // or pdf.LoadFromDataSet > pdf.AutoPaginate := True; > pdf.AddPage; > pdf.AddObject(VLabel); > pdf.AddObject(VMemo); > pdf.AddObject(VImage); > pdf.Print('print.pdf'); // or pdf.Print to print as DataURI Why jsPDF and no FPDF (https://github.com/jepafi/Free-JPDF-Pascal)? Marcos Douglas PS: or my fork https://github.com/mdbs99/Free-JPDF-Pascal

jsPDF have more reatures. :)

Silvio Cl?cio My public projects - github.com/silvioprog -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130117/1a8b891c/attachment.html>

Reply by email

silvioprog
to Leonardo M. Ramé: Yes, te attached file generates a report based on a TCollection containing the data for…

2013/1/17 Leonardo M. Ram?

Show quoted text 59 lines
On 2013-01-17 09:07:09 -0200, silvioprog wrote: > 2013/1/17 Leonardo M. Ram? <[1]> > > On 2013-01-17 08:52:11 +0100, Michael Van Canneyt wrote: > > > > On Wed, 16 Jan 2013, silvioprog wrote: > > > > >Hello, > > >Please see in: > > > > > >[2]http://bugs.freepascal.org/view.php?id=23664 > > > > This cannot be fixed. Lazreport is not suitable for use in > webapplications. > > > > Some time ago, I started a new reporting engine exactly for this > reason. > > > > A well-designed reporting engine is independent of any widget set. > > (see e.g. jasperreports in Java) > > > > Michael. > > > > I had a similar issue some time ago with, TAChart. It needed TCanvas to > draw charts, but that was fixed by Alexander, if I remember correctly. > > That's why I stopped looking for a report generator for my cgi apps. Now > I rely on libHaru ([3]http://libharu.org/), which is a C shared library > with Pascal bindings that allows creation of PDF files. > > The problem with libHaru is you don't create reports out of markup, but > by code. In my case that's not a problem, because I'm the only one in > charge of creating reports, a different story will be when the final > user wants to create their own reports. > -- > Leonardo M. Ram? > [4]http://leonardorame.blogspot.com > > Very nice. > You could send a small example with this library to take a look? Thank > you. > -- Yes, te attached file generates a report based on a TCollection containing the data for each page, it has a header, body (with many lines) and a footer. I also attached a small jpg showing the final report. -- Leonardo M. Ram? http://leonardorame.blogspot.com

Thank you very much, I'll see this... :)

Silvio Cl?cio My public projects - github.com/silvioprog -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130117/1314e2f6/attachment-0001.html>

Reply by email

Marcos Douglas
to Michael Van Canneyt: Why did you fork this ? Michael.
Michael Van Canneyt wrote 58 lines
On Thu, 17 Jan 2013, Marcos Douglas wrote: > On Thu, Jan 17, 2013 at 7:52 AM, silvioprog wrote: >> >> >> 2013/1/17 Michael Van Canneyt >>> >>> >>> On Thu, 17 Jan 2013, Sven Barth wrote: >>> >>>> Am 17.01.2013 08:52, schrieb Michael Van Canneyt: >>>>> >>>>> >>>>> Some time ago, I started a new reporting engine exactly for this >>>>> reason. >>>>> >>>> And how far is your progress with that? Which reminds me that I should >>>> finally test the new database search provided in packages... -.- >>> >>> >>> >>> It is currently dormant; I had finished the looping logic, if memory >>> serves well. >>> >>> Michael. >> >> >> >> I've been thinking of porting jsPDF for Free Pascal: >> >> http://jspdf.com >> >> But, using inheritance, something like (a pseudo example): >> >> VLabel.Text := 'Hello'; >> VLabel.Font.Style := [fsBold]; >> VMemo.Lines.Add('Line 1'); >> VMemo.Lines.Add('Line 2'); >> VMemo.Font.Align := faJustify; >> ... >> pdf.LoadFromJSON(<JSON>); // or pdf.LoadFromDataSet >> pdf.AutoPaginate := True; >> pdf.AddPage; >> pdf.AddObject(VLabel); >> pdf.AddObject(VMemo); >> pdf.AddObject(VImage); >> pdf.Print('print.pdf'); // or pdf.Print to print as DataURI > > > Why jsPDF and no FPDF (https://github.com/jepafi/Free-JPDF-Pascal)? > > Marcos Douglas > PS: or my fork https://github.com/mdbs99/Free-JPDF-Pascal Why did you fork this ?

Because the author do not have time to work in this project at moment (I sent a fix for a memleak and until now wasn't merged). I proposed to him codify a class following the FPHP stylish but he won't change the current code.

Marcos Douglas

Reply by email

Marcos Douglas
to Michael Van Canneyt: Well, I was looking at this too for a PDF backend. Finally, it was the dependency on…
Michael Van Canneyt wrote 56 lines
On Thu, 17 Jan 2013, Graeme Geldenhuys wrote: > On 01/17/13 10:52, silvioprog wrote: >> >> >> I've been thinking of porting jsPDF for Free Pascal: > > > > fpGUI also has a small PDF reporting engine. To see what it can do, take > a look at the demo in <fpgui>\examples\gui\reporting > > Some features: > * Text output (obviously) > * Text attributes (color, size, font, alignment etc) > * Image support > * Drawing primitives > * Headers, Footers > * Sections > * Grids > * Page numbers, Section numbers > * Page attributes (landscape, portrait, mixed, pages sizes etc) > * PDF attributes (eg: when file is opened go full screen or 2-up etc) > * Print Preview (this is dependent on fpGUI of course, but it is a > separate unit, so isn't a problem) > > It doesn't bind to datasets etc. You simply iterate whatever data you > want, and write whatever to the PDF's canvas. This gives you the most > flexibility and allows creating reports from anything (business objects, > datasets, stringgrid etc). > > Currently the PDF engine has very little dependency on fpGUI - a data > type which could be easily redefined in the reporting unit itself, and > some color utility methods, which again could be redefined in the > reporting units themselves. > > I'm using this PDF engine to generate rather complex reports in our > commercial apps, reporting from tiOPF-based business objects. It works > very well. > > An French developer wrote and contributed this to the fpGUI project. > Some classes and methods are still in French though, but if you look at > the demo project and its demo reports, it is easy to figure out. We are > still working on translating everything to English. If you do try it out > and hit a problem, you are welcome to post questions in the > fpgui.support newsgroup (see the website for details). Well, I was looking at this too for a PDF backend. Finally, it was the dependency on fpGUI that stopped me from using it. If we can make sure there is no such dependency, I'd very much like to have it in FPC itself.

Nice!

Marcos Douglas

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt: Well, I was looking at this too for a PDF backend. Finally, it was the dependency on…
Michael Van Canneyt wrote
If we can make sure there is no such dependency, I'd very much like to have it in FPC itself.

I'm sure something could be worked out. Like I said, there is actually very little dependency on fpGUI.

A quick browse through the code (see the src/reporting directory) I can see the TfpgColor type (simple record structure), 3 color extraction methods (Reg, Green and Blue), and one or two RTL wrapper functions for Unicode filename support - these will take about 20 minutes to fix and test.

Then there is TfpgImage for Image embedding in PDF's. The Image support was one of the last things to be added to the PDF engine. The PDF reporting already worked very well before Image support was added. Anyway, I'm quite confident that the TfpgImage usage could easily be abstracted out. TfpgImage is just a container for the raw image data.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

silvioprog
to Michael Van Canneyt: This cannot be fixed. Lazreport is not suitable for use in webapplications. Some time…

2013/1/17 Michael Van Canneyt
[...]

Some time ago, I started a new reporting engine exactly for this reason.

When launched FPreport, I'll create a Brook's broker for it. :)

Silvio Cl?cio My public projects - github.com/silvioprog -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130117/249c99d8/attachment.html>

Reply by email

Alexander Klenin
to Michael Van Canneyt: This cannot be fixed. Lazreport is not suitable for use in webapplications. Some time…
Michael Van Canneyt wrote
This cannot be fixed. Lazreport is not suitable for use in webapplications.

I am curious -- can you elaborate on the reasons for that? I can understand the dependency on the concept of widgetset, but why nogui is not sufficient?
As I remember, the most serious issue I encountered while porting TAChart to nogui
was inadequate font support in FPC, but we have LazFreeType now... (BTW, I should try LazFreeType in TAChart...)

Alexander S. Klenin

Reply by email

Alexander Klenin
to leledumbo
leledumbo wrote
Alex, could you try porting LazReport to nogui?

Aside: "Alex", "Alexey" and "Alexander" are very different names in Russian. Please do not confuse me by using the wrong name ;)

AFAIR, the problem is the same as TAChart, it requires to draw somewhere.

I have taken a look. Unfortunately, the LazReport turned put to be almost exactly equivalent
to old FastReport library (most units even still retain copyright header from there).
Which is bad news, becase FastReport/LazReport is, shall we say, not an example of proper design.
Most basic units, including LR_Class, use not only Graphics, but Forms, Dialogs, Menus, and more.
There are inexplicable things like
try ... except ShowMesage(...) end
calls to MessageDlg from the setter of TfrObject.Name property, etc. I see several possible ways forward here:
1) Add a lot of IFDEFs. In the general case, mass-IFDEFs are horrible idea, but this code is already a pain to look at, and selecting nogui widgetset is compile-time decision anyway,
so perhaps it is feasible.
2) Do a "slow rewrite", by progressively rfactoring and improving code, with gradual breaks of compatibility and
appropriate deprecation periods, until the code gets in decent shape. This is a "proper" way, but requires much work and time -- about a year for the dedicated maintainer.
3) Do a "fast rewrite" -- just throw away this code and use something else, or write it from scratch. This is basically what everyone else in this thread are suggesting. As much as I dislike "second system syndrome" (http://www.joelonsoftware.com/articles/fog0000000069.html), this might be a reasonable course in this case.

Alexander S. Klenin

Reply by email

Michael Van Canneyt
to Alexander Klenin: On Thu, Jan 17, 2013 at 6:52 PM, Michael Van Canneyt I am curious -- can you elaborate on…
Alexander Klenin wrote 9 lines
On Thu, Jan 17, 2013 at 6:52 PM, Michael Van Canneyt wrote: > > > This cannot be fixed. Lazreport is not suitable for use in webapplications. I am curious -- can you elaborate on the reasons for that? I can understand the dependency on the concept of widgetset, but why nogui is not sufficient?

Because I do not consider noGUI a valid solution.
It is a totally misguided concept.

I'm sure the lazarus devs had their reasons for introducing it, but it is one of their worst decisions ever (in my opinion).

They should have fixed the original problems properly: i.e. remove all erroneously introduced GUI dependencies, so nogui was not needed to begin with.
(I am aware that this might have taken more time)

Look at jasperreports in Java.
It's core has no gui dependencies, and that is how it should be.

Michael.

Reply by email

Michael Van Canneyt
to Alexander Klenin: Aside: "Alex", "Alexey" and "Alexander" are very different names in Russian. Please do…
Alexander Klenin wrote 5 lines
3) Do a "fast rewrite" -- just throw away this code and use something else, or write it from scratch. This is basically what everyone else in this thread are suggesting. As much as I dislike "second system syndrome" (http://www.joelonsoftware.com/articles/fog0000000069.html), this might be a reasonable course in this case.

Which was exactly my conclusion when I looked at it, and so I started fpReport :-)

Unfortunately, time constraints are everything :(

Michael.

Reply by email

Sven Barth
to Alexander Klenin: Aside: "Alex", "Alexey" and "Alexander" are very different names in Russian. Please do…
Alexander Klenin wrote
On Sat, Jan 19, 2013 at 4:17 PM, leledumbo wrote: > Alex, could you try porting LazReport to nogui? Aside: "Alex", "Alexey" and "Alexander" are very different names in Russian. Please do not confuse me by using the wrong name ;)

Well, there are people that prefer a shorter version of their name... For example I know a "Alexandra" which prefers to be called "Alex". :)

Regards,
Sven

Reply by email

Alexander Klenin
to Michael Van Canneyt: Because I do not consider noGUI a valid solution. It is a totally misguided concept. I'm…
Michael Van Canneyt wrote
I do not consider noGUI a valid solution. It is a totally misguided concept. I'm sure the lazarus devs had their reasons for introducing it, but it is one of their worst decisions ever (in my opinion).

Actually I think nogui is a valid workaround.
Of course, correct GUI/logic separation would be better, but it is much harder to achieve,
especially while maintaining backwards compatibility. For example, it took maybe two days of work to convert TAChart to nogui, and, while not pretty, it does work, as evidenced in this thread. At the same time, "correct" solution must wait for new FPC version, for even the first attempt,
and even then I am not sure it will be possible.

Which was exactly my conclusion when I looked at it, and so I started fpReport :-) Unfortunately, time constraints are everything :(

Yes, so it is conceivable that a "fast" rewrite will require two years while "slow" one could be done in only one year :)

Alexander S. Klenin

Reply by email

Michael Van Canneyt
to Alexander Klenin
Alexander Klenin wrote 8 lines
On Sat, Jan 19, 2013 at 9:14 PM, Michael Van Canneyt wrote: > I do not consider noGUI a valid solution. It is a totally misguided concept. > > I'm sure the lazarus devs had their reasons for introducing it, > but it is one of their worst decisions ever (in my opinion). Actually I think nogui is a valid workaround.

exactly: a workaround.

I want a real solution.

"Aut Caesar, aut nihil."

Michael.

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt: Because I do not consider noGUI a valid solution. It is a totally misguided concept. I'm…
Michael Van Canneyt wrote 6 lines
Because I do not consider noGUI a valid solution. It is a totally misguided concept. I'm sure the lazarus devs had their reasons for introducing it, but it is one of their worst decisions ever (in my opinion).

+1

Couldn't say it better if I tried.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Graeme Geldenhuys
to Alexander Klenin: On Sat, Jan 19, 2013 at 9:14 PM, Michael Van Canneyt Actually I think nogui is a valid…
Alexander Klenin wrote
Actually I think nogui is a valid workaround.

They key point here is "workaround"

Of course, correct GUI/logic separation would be better, but it is much harder to achieve,

We become developers knowing that we will have tough problems to solve. That's the joys of developing (at least for me).

For example, it took maybe two days of work to convert TAChart to nogui, and, while not pretty, it does work, as evidenced in this thread.

And again, the key here is "not pretty". That doesn't bode well in any software.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email