Page Break

edited 7:23AM in FastReport VCL
Hi All

I have built a report with about 10 headers / master data pairs on it. During print is usually occupies 3 - 5 pages. My users have complained some times where only the header shows up on one page, and the rest on the next page. Obviously, this is the nature of a "single page" report being printed on multiple pages. Depending on the amount of data to print, most of the times, the users are happy. In some cases I would like to start a new page only if the header only is printet on the last page, and possibly if only a few rows can be printed. How can I check how many lines will be printed for a header / master data pair? I mean, lets say if only the header and two lines can be printed on a page, I would like to break the whole header and master data over to the next page.

Thanks for any information. Using FR6 and Delphi 10.2

Eivind

Comments

  • PolomintPolomint Australia
    edited May 2018
    G'day Eivind,

    Have you tried checking the FreeSpace against the Height(s) of any Band(s) you need to print, in the BeforePrint event(s) for the Band(s)?

    Below is an extract from one of our reports that forces a new page if there is insufficient space to print a sub-heading and detail band.

    Please note our reports are all "two pass" type.

    Cheers, Paul

    NB: Simplified to highlight the key steps.
    procedure TGLOWreportTaxReturn.DetailBandBeforePrint (Sender : TfrxReportComponent; var PrintBand : Boolean);
    begin
      PrintBand := SomeFunctionToDecideIfBandPrints;
    
      if PrintBand then
        with Report.Engine do begin
          if FreeSpace < DetailBand.Height + SubheadingFooter.Height then
            NewPage;
        end;
    end; {TGLOWreportTaxReturn.DetailBandBeforePrint}
    

    NB: You need to instantiate the variables referring to the Bands in your Report's BeginDoc Event (the string constants used have to exactly match the spelling in the Report definition):
      // get Band objects...
      DetailBand := FindObject (consDetailBand) as TfrxMasterData;
      LineItemHeader := FindObject (consLineItemHeader) as TfrxGroupHeader;
      NonrefundableOffsetsFooter := FindObject (consReportNonrefundableOffsetsFooter) as TfrxChild;
      ReportFooter := FindObject (consReportFooter) as TfrxReportSummary;
      RefundableOffsetsFooter := FindObject (consReportRefundableOffsetsFooter) as TfrxChild;
      SubheadingFooter := FindObject (consSubheadingFooter) as TfrxGroupFooter;
      SubheadingHeader := FindObject (consSubheadingHeader) as TfrxGroupHeader;
    

    And the variables themselves have to be manually created in the Private declarations of the Form containing your Report:
        DetailBand : TfrxMasterData
        LineItemHeader : TfrxGroupHeader;
        NonrefundableOffsetsFooter : TfrxChild;
        RefundableOffsetsFooter : TfrxChild;
        ReportFooter : TfrxReportSummary;
        SubheadingFooter : TfrxGroupFooter;
        SubheadingHeader : TfrxGroupHeader;
    
    --- Ends ---
  • edited 7:23AM
    Thanks for the pointers Paul!

    They appeared to solve my page break issues

    Cheers

    Eivind
  • PolomintPolomint Australia
    edited 7:23AM
    >

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.