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

How Can I make a print log file ?

edited March 2006 in General
Hi ,
I have RB enterprise 9.03 /Delphi 7 /end user,
I want to make a print log file (which files are printed to paper -not
preview)

When I try to write a code on RBRaporAfterPrint or RBRaporBeforePrint event
of Tppreport , its not work ,
My report designs are stored then sql server, and I call report like this,

ReportExplorer.LoadReport(ReportCaption,Reportid);
RBReport.DeviceType := dtScreen; // Preview
RBReport.Print;


How can I catch the report print and do something (printer log - which files
are printed) there ?


******************************************************
procedure TFormRapor.RBRaporAfterPrint(Sender: TObject);
begin
ShowMessage ('RBRaporAfterPrint') ; //its not work
end;

Comments

  • edited March 2006
    Hi Kemal,

    If you are loading reports from the report explorer, the events you have
    assigned to the Report object are going to be ignored. Since you are using
    RB Enterprise, I would recommend using RAP to implement the events
    associated with each report. Try adding the same code to the AfterPrint
    event in RAP and you will see a message.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2006
    Thnx its work,
    But I must do this from source code, not in report design,
    I Have got many report and I can't write this code all of them, I must catch
    this even on RBRaporAfterPrint,
    Can I prevent ignoring RBRaporAfterPrint event by report explorer anyway
    ?


  • edited March 2006
    Hi Kemal,

    One option would be to assign the after print event to each report after the
    template has already been loaded. This could be done using the template
    event OnLoadEnd. See the following article on using Template events.

    ----------------------------------------------
    Tech Tip: Using Template Events
    ----------------------------------------------

    The Report.Template object has several events that can be used for
    customizing what happens when a report is loaded or saved:

    - OnLoadStart
    - OnLoadEnd
    - OnNew
    - OnSaveStart
    - OnSaveEnd


    The OnLoadEnd and OnNew events are often used to perform actions related to
    report and data initialization.

    The OnSaveEnd event is often used to save additional descriptive ("meta")
    data to the database each time the report is saved.

    Example:

    The Report.Template events are public and therefore must be assigned at
    run-time.


    1. In the private section of your form declaration you can declare an
    event-handler method:

    TForm = class(TForm)
    private
    procedure myTemplateOnLoadEndEvent(Sender: TObject);

    public

    end;


    2. In the Form.OnCreate event, you can assign the event-handler to the
    event:

    procedure TForm1.FormCreate(Sender: TObject);
    begin

    ppReport1.Template.OnLoadEnd := myTemplateOnLoadEndEvent;

    end;


    3. Implement the event-handler method:

    procedure TForm1.myTemplateOnLoadEndEvent(Sender: TObject);
    begin

    {add code here to initialize the report or data, etc. }
    ppReport1.PrinterSetup.MarginTop := 0.5;

    end;


    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2006
    Hi Nico ,
    Thanx for your suggestions , its usefull but I think there is a problem like
    that,

    procedure TFormReport.MyTemplateOnLoadEndEvent(Sender: TObject);
    begin
    ShowMessage ('On Load End Executed') ;
    RBReport.AfterPrint := RBReportAfterPrint ;
    end;

    procedure TFormReport.RBReportAfterPrint(Sender: TObject);
    begin
    ShowMessage ('RBReportAfterPrint');
    end;

    Son When I try to close my report preview screen (without printing) , its
    alway go to RBReportAfterPrint,
    but I want that the RBReportAfterPrint event only run when user send report
    to the printer,
    Why the 'RBReportAfterPrint' event execute on close preview screen ?
    Can I execute this event only and only when the user send report to the
    printer ?



  • edited March 2006
    ------------------------------------------
    Tech Tip: Detecting whether Report was
    Printed to the Printer
    ------------------------------------------

    The Report.AfterPrint event can be used to
    determine whether the report was printed
    to the printer (rather than preview, ...).


    Example:


    procedure TForm1.ppReport1AfterPrint(Sender: TObject);
    begin

    if (ppReport1.PrinterDevice <> nil) then
    ShowMessage('Report was printed to the printer');

    end;



    Note: If the user cancels the report while it
    is running, then the Report.OnCancel event will
    fire, followed by the Report.AfterPrint event.

    Example:

    procedure TForm1.ppReport1Cancel(Sender: TObject);
    begin
    ShowMessage('Printing cancelled by user');

    end;


    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2006
    Thanx Nico , Its work ,




This discussion has been closed.