PageFooter1.OnAfterPrint makes FastReports crash

edited July 2018 in FastReport VCL
Hello,

I would like to display a page containing the same text after displaying each "normal" page containing a MasterData band (so there would be the datas on the recto and the text on the verso of each page).
I know at least one question like this has been asked on this forum before, but it was in 2009 so maybe some things changed, for example the available duplex options don't seem to be the same.

A solution I was thinking about is to call a code like
Engine.NewPage;
Engine.ShowBand(PageHeader2);
Engine.NewPage;
In the OnAfterPrint method of PageFooter of Page1, with the possibility to replace PageHeader2 with whatever I want later.
But each time I call PageFooter1.OnAfterPrint (or OnBeforePrint), previewing the report makes FastReports crash. Is there a reason to that ? Is it the expected behavior from FastReports ?

Of course, any suggestion allowing me to achieve what I want in an other way is welcome. My main problem is that a row of MasterData is likely to be quite long, and I want to be able to split it (so there could be a text page inserted in the middle of a masterData row). Maybe I should post an other topic for that ?

regards,

Florent

Comments

  • edited July 2018
    Hello again,

    I didn't get any answer about PageFooter1 's behavior, but I finally found a solution to my problem by myself and with some help from the Fastreport support, so I write it here in case that could help someone one day.
    For me it consists of making a Page2 with just an empty header and a child attached to it, which contains my "verso page".
    Then I added the code
    procedure PageHeader1OnBeforePrint(Sender: TfrxComponent); // Before printing the header of Page1
    begin
      // Using this "printVerso" variable can be usefull if you want to be
      // able to easily activate or deactivate printing the verso page
      if(Get('printVerso') AND (Get('Page#') mod 2 = 0)) then
        begin
          Engine.ShowBand(Child2); // Showing the band containing the verso page
          PageHeader1.Visible := False;
          PageFooter1.Visible := False;
    	  // Do the same operations on the visibility of PageHeader's eventual children
    	  // if you've set PagHeader1's "Print Child If Invisible" property to true.
          Engine.NewPage;
          PageHeader1.Visible := True;
          PageFooter1.Visible := True;
        end;
    end;
    
    // In the main procedure
    begin;
      if (NOT Get('printVerso')) then
          Page2.Visible := False;                                                        
        end;     
    end.
    

    That way if the content of Page1 normally takes 3 pages, the visual result will be
    Page1
    Page2
    Page1
    Page2
    Page1
    Page2
    with the same content for Page2 each time it's printed, which is what I want.

    You can also do lots of things from Delphi or C++, playing with the previewPages attribute of your TfrxReport like here https://www.fast-report.com/en/blog/151/show/

    regards,

    Florent

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.