OnPrintPage

edited January 2009 in FastReport 4.0
Hello,

i run into the following problem:

After assigning
procedure TForm.frReportPrintPage(Page: TfrxReportPage; CopyNo: Integer);
begin
page.LeftMargin := 100;
page.RightMargin := 100;
page.TopMargin := 100;
page.BottomMargin := 100;
end;


and printing report with
frReport.PrepareReport;
frReport.Print;
calls the OnPrintPage Event, and everything is fine but

preview report with
frReport.PrepareReport;
frReport.ShowPreparedReport;
or
frReport.ShowReport;
don't calls the Event OnPrintPage!!!!!

What i am doing wrong?

Delphi 2007
Fastreport 4.7.31

Thanks,
Patrick

Comments

  • edited 12:22PM
    Hi,

    any idea for this problem?

    Thanks,
    Patrick
  • gpigpi
    edited 12:22PM
    TfrxReport.OnPrintPage calls when TfrxReport is printed
    Try to use TfrxReport.OnBeforePrint event
  • edited 12:22PM
    gpi wrote: »
    TfrxReport.OnPrintPage calls when TfrxReport is printed
    Try to use TfrxReport.OnBeforePrint event


    but in TfrxReport.OnBeforePrint i can't set margins for page!
    OnPrintPage is the only way i know to set margins...

    Maybe you know another?

    Thanks,
    Patrick
  • gpigpi
    edited 12:22PM
    Sorry, try TfrxReport.OnBeginDoc
    procedure TForm1.frxReport1BeginDoc(Sender: TObject);
    var page: TfrxReportPage;
    begin
         Page:=TfrxReportPage(frxReport1.FindObject('Page1'));
         Page.LeftMargin:=20;
         Page.RightMargin:=10;
         Page.TopMargin:=10;
         Page.BottomMargin:=10;
    end;
    
  • edited 12:22PM
    gpi wrote: »
    Sorry, try TfrxReport.OnBeginDoc
    procedure TForm1.frxReport1BeginDoc(Sender: TObject);
    var page: TfrxReportPage;
    begin
         Page:=TfrxReportPage(frxReport1.FindObject('Page1'));
         Page.LeftMargin:=20;
         Page.RightMargin:=10;
         Page.TopMargin:=10;
         Page.BottomMargin:=10;
    end;
    

    ...thanks for your answer, but "Page" is always nil in this event...

    Patrick
  • edited 12:22PM
    Hi,

    someone else can help me to set page margins in preview?

    Thanks,
    Patrick
  • gpigpi
    edited 12:22PM
    wrote:
    ...thanks for your answer, but "Page" is always nil in this event...
    Is Page1 TfrxReportPage exists in your report?
    wrote:
    someone else can help me to set page margins in preview?
    Use
    procedure TForm1.frxReport1BeginDoc(Sender: TObject);
    var page: TfrxReportPage;
    begin
         Page:=TfrxReportPage(frxReport1.FindObject('Page1'));
         Page.LeftMargin:=20;
         Page.RightMargin:=10;
         Page.TopMargin:=10;
         Page.BottomMargin:=10;
    end;
    
    or
    var page: TfrxReportPage;
    begin
         Page:=TfrxReportPage(frxReport1.FindObject('Page1'));
         Page.LeftMargin:=20;
         Page.RightMargin:=10;
         Page.TopMargin:=10;
         Page.BottomMargin:=10;
         frxReport1.ShowReport;
    end;
    

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.