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

Paper tray selection controlled by template?

edited February 2003 in General
Hi,

One can use Delphi code for selecting paper bins for each report page.
That's okay. But now I long to know how the end-user can specify the paper
tray for each page within the template, conrolled by an event like this:

procedure ReportOnStartPage;
begin
if Report.AbsolutePageNo = 1 then
Report.PrinterSetup.BinName := 'Tray 1'
else
Report.PrinterSetup.BinName := 'Tray 2';
end;

Is there any proper solution?

Thanks in advance.

Michael

Comments

  • edited February 2003
    Create a RAP pass through function to set it on the page object in the
    OnStartPage or OnEndPage event. Your user will use this event handler in
    RAP, and the code they should call is your SendReportPageToPrinterBinName
    pass through function like:

    procedure OnEndPage;
    begin
    if Report.AbsolutePageNo = 1 then
    SendReportPageToPrinterBinName(Report, 'Tray 1')
    else
    SendReportPageToPrinterBinName(Report, 'Tray 2');
    end;

    You pass through function will need to pull the report obect form the first
    parameter of the pass through function and then you can get at the
    Report.Engine.Page object in the dephi code of you pass through funciton in
    order to set the printer setup bin name (second pass thorugh function
    parameter) on the page object.

    Cheers,

    Jim Bennett
    Digital Metaphors

    --------------------------------------------
    Tech Tip: Selecting Paper Bins for Each Page
    --------------------------------------------


    Sometimes you may want to print the first page of a report to the
    manual bin and then print the remaining pages to the default bin.

    You can use the Report.OnStartPage event to set the bin for any page.


    Example:

    procedure TForm1.ppReport1OnStartPageEvent(Sender:TObject);
    var
    lsBinName: String;

    begin

    if ppReport1.AbsolutePageNo = 1 then
    lsBinName := ppReport1.PrinterSetup.BinNames[3]
    else
    lsBinName := ppReport1.PrinterSetup.BinNames[1];


    ppReport1.Engine.Page.PrinterSetup.BinName := lsBinName;


    end;



    Note: The above example assumes the manual bin is 4th in the list (remember
    its a 0 based index). To account for different print drivers, you could
    search for the 'manual' bin in code by performing a search on the printer's
    available bin names:

    for liBin := 0 to ppReport1.PrinterSetup.BinNames.Count-1 do
    if Pos('manual', ppReport1.PrinterSetup.BinNames[liBin]) > 0 then
    begin
    lsBinName := ppReport1.PrinterSetup.BinNames[liBin];
    break;

    end;


    --
    Tech Support mailto:support@digital-metaphors.com
    Digital Metaphors http://www.digital-metaphors.com





  • edited February 2003
    I forgot to mention that there are examples of creating RAP pass through
    functions in your installed demos directory in the RAP folder.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited February 2003

This discussion has been closed.