Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

never-ending with specific data

edited May 2003 in General
I have a never-ending report with a specific set of data. In other
cicumstances, or if I edit the data, everything is printing correctly.

The report consist of a detail SubReport in a group footer. In this Sub
Report, there is also a detail subreport.

The two subreports contains only images. The first one, two images with
static height, and the second one a single image with a dynamic height.

In a particular set of data, the last page is not able to finish to
generate. There is my first image (in first subreport), then the second
image is set to height:=0 because the imageField is null. Then I get a
blank page. After this blank page, if I click the next button in preview,
it tries to generate the last page (with the image) for ever, is never able
to finish. Setting some breakpoint in Delphi, I see that the band's
beforegenerate event is called over and over in a infinite loop.

Here is the code I use in the detail band's BeforeGenerate (I am very open
to advices):

//first detail band with 2 static height images
procedure TfCheque.ppDetailBand6BeforeGenerate(Sender: TObject);
var
msTemp:TMemoryStream;
TempTif:TTiffGraphic;
begin
inherited;
//load the image from DB
msTemp := TMemoryStream.Create;
TempTif := TTiffGraphic.Create;
try
if not qDistribReportFront.IsNull then
begin
qDistribReportFront.SaveToStream(msTemp);
msTemp.Position := 0;
TempTif.LoadFromStream(msTemp);
ppImgFrontEmail.Picture.Assign(TempTif);
ppImgFrontEmail.Height := 3.6;
ppImgFrontEmail.Visible := True;
end
else
begin
ppImgFrontEmail.Height := 0;
end;
msTemp.Clear;
if not qDistribReportBack.IsNull then
begin
qDistribReportBack.SaveToStream(msTemp);
msTemp.Position := 0;
TempTif.LoadFromStream(msTemp);
ppImgBackEmail.Picture.Assign(TempTif);
ppImgBackEmail.Height := 3.6;
ppImgBackEmail.Visible := True;
end
else
begin
ppImgBackEmail.Height := 0;
end;
finally
msTemp.Free;
TempTif.Free;
end;
end;


//second detail with 1 dynamic height image.
procedure TfCheque.ppDetailBandStubsEmailBeforeGenerate(Sender: TObject);
var
msTemp:TMemoryStream;
TempTif:TTiffGraphic;
begin
inherited;
//load the image from DB
if not qChequeImageIMAGE.IsNull then
begin
msTemp := TMemoryStream.Create;
TempTif := TTiffGraphic.Create;
try
qChequeImageImage.SaveToStream(msTemp);
msTemp.Position := 0;
TempTif.LoadFromStream(msTemp);
if TempTif.Height>900 then
ppiStubEmail.Height := 10.5
else
ppiStubEmail.Height:= 3.5;
ppiStubEmail.Picture.Assign(TempTif);
ppiStubEmail.Visible := True;
finally
msTemp.Free;
TempTif.Free;
end;
end
else
ppiStubEmail.Height := 0;
end;

Comments

  • edited May 2003
    You have managed to create a report that has a static height control that
    cannot fit on a given page. You'll have to find out which page the control
    can't fit on and debug your code which resizes the control such that it
    can't fit. Find out the max height you can have and make this the default
    when the height calculation exceeds this value. That is what is happening in
    your report. RB will keep requesting pages because it can't fit a static
    height control on the previous page.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited May 2003
    > cannot fit on a given page. You'll have to find out which page the control
    in

    That is what I am already doing...


    I am pretty sure that it is the ppiStubEmail component that is causing the
    problem. In the page that doesn't generate, the ppiStubEmail.Height is set
    to 10.5, wich is my maximum value.

    If, instead of using 10.5, I set it to 2.0 or 3.0 (to be sure that it fit),
    I still get the same behavior, so it is not that the image cannot fit in the
    page. The report shows a blank page and then is not able to generate the
    next page. It's not an infinite number of pages, it's that the page is
    never generated. If I insert data after this record, it freezes at the same
    record, so it is not because it is the last page or something like that.

    In this record, the height of the previous image is set to 0 because the
    image field is null. If I insert an image (anyone) in this field, the
    report generates correctly. And of course, If I delete the big image that
    is supposed to be 10.5 high, it generates correctly too. If I replace the
    big image with a small one, it doesn't get generated.

    I really don't understand what is going on.
  • edited May 2003
    Believe it or not I solved the problem by adding a group on the Primary key
    and forcing a new page.
    Now I have a working report. I don't mind if it takes 2-3 more pages at the
    end. I only needs theses images to print.

  • edited May 2003
    If you would like to send an example report that we can easily run here we
    can look at it to see what is happeneing, even though you have a workaround.
    Perhaps there is an issue that needs to be fixed or there is a problem in
    the layout that is causing a problem. Send it to
    support@digital-metaphors.com


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited May 2003
    > If you would like to send an example report that we can easily run here we
    workaround.

    I'd really like to send you an example, but it involves a lot of work (this
    is a 100 forms project and the database is quite big). If I have nothing
    rush to do, I'll try to create something to send to you. After 5 hours of
    headache on this report, I don't want to spend another minute on it this
    week...

    Thanks a lot for your support.
    Don't be affraid, I'm still thinking that ReportBuilder is the best
    Reporting tool for Delphi.

    Fred.
  • edited May 2003
    "Jim Bennett (Digital Metaphors)" wrote in
  • edited May 2003
    Thanks for the suggestion! It is on the To-Do list.


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.