Recent

Author Topic: LAZREPORT - HELP COMPOSITE  (Read 3159 times)

wcleyton

  • Jr. Member
  • **
  • Posts: 80
LAZREPORT - HELP COMPOSITE
« on: May 15, 2014, 02:49:34 pm »
 Good morning,

I have several reports of 1 page. I would like to print several of them simultaneously.

I tried to COMPOSITE. I could not!  :'(

Attached is a small project as I am trying and 3 reports I recorded with LazReport.

What am I doing wrong?  :o

Grateful for the attention.

wcleyton

  • Jr. Member
  • **
  • Posts: 80
Re: LAZREPORT - HELP COMPOSITE
« Reply #1 on: May 15, 2014, 09:51:18 pm »
Good afternoon,

Any idea how combining all 3 reports?

I have attached a small example with the problem in the first post.

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 753
Re: LAZREPORT - HELP COMPOSITE
« Reply #2 on: May 16, 2014, 03:02:30 am »
hello,
it seems that composite doesn't work with preparedreport.

to combine your 3 prepared reports you can try this :
1 - create a new procedure AddPreparedReport in the tfrReport class  ( file LR_Class.pas) of lazreport package :
Code: [Select]
procedure AddPreparedReport(const FName: String);   
.....
procedure TfrReport.AddPreparedReport(const FName: String);
var
  Stream: TFileStream;
begin
  Stream := TFileStream.Create(UTF8ToSys(FName), fmOpenRead);
  EMFPages.AddPagesFromStream(Stream);
  Stream.Free;
  CanRebuild := False;
end;   

and now to use this new procedure :
Code: [Select]
procedure TForm1.Button2Click(Sender: TObject);
var
  r,rx: TfrReport;
  report1:string;
  report2:string;
  report3:string;
  PathApp: String;
begin
  PathApp := ExtractFilePath(ParamStrUTF8(0));
  if PathApp[Length(PathApp)]<>PathDelim then PathApp := PathApp+PathDelim;
  report1 := 'report1.nkm';
  report2 := 'report2.nkm';
  report3 := 'report3.nkm';
  r:=TfrReport.create(self);
  r.LoadPreparedReport(PathApp+report1);
  r.AddPreparedReport(PathApp+report2);
  r.AddPreparedReport(PathApp+report3);
  r.ShowPreparedReport;
  r.Free;
end;

if you don't want modify LR_Class file, you can try this :
Code: [Select]
procedure TForm1.Button2Click(Sender: TObject);
var
  r,rx: TfrReport;
  report1:string;
  report2:string;
  report3:string;
  PathApp: String;
  Stream: TFileStream;
begin
  PathApp := ExtractFilePath(ParamStrUTF8(0));
  if PathApp[Length(PathApp)]<>PathDelim then PathApp := PathApp+PathDelim;
  report1 := 'report1.nkm';
  report2 := 'report2.nkm';
  report3 := 'report3.nkm';
  r:=TfrReport.create(self);
  r.LoadPreparedReport(PathApp+report1);
  Stream := TFileStream.Create(UTF8ToSys(PathApp+report2), fmOpenRead);
  r.EMFPages.AddPagesFromStream(Stream);
  Stream := TFileStream.Create(UTF8ToSys(PathApp+report3), fmOpenRead);
  r.EMFPages.AddPagesFromStream(Stream);
  r.ShowPreparedReport;
  Stream.Free;
  r.Free;
end;

friendly, J.P
« Last Edit: May 16, 2014, 03:22:21 am by Jurassic Pork »
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

wcleyton

  • Jr. Member
  • **
  • Posts: 80
[SOLVED] - Re: LAZREPORT - HELP COMPOSITE
« Reply #3 on: May 16, 2014, 01:41:06 pm »
SOLVED!

Thank you very Jurasic Pork!

It would be possible to add this procedure in LazReport (AddPrepareReport)?