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

How to ensure a label printing at the end.

edited September 2001 in General
I have a standard procedure that making a label to print it at the end.
i.e *** End of Report ***' and place it on sammary band and using the
inherited

But for some reports, that is a sub-report in sammary band. I don't know how
to set it in the procedure that ensure the label is at the end ?

Comments

  • edited September 2001
    You could set the label to ShiftRelativeTo the subreport, if a subreport
    exists in the summary band. The band has an objects array property which
    you can loop through looking for a subreport component by checking its class
    type. There is an article on looping through the objects in the CodeBased
    thread of the tech-tips newsgroup.

    Otherwise, it may be possible to use a draw command approach and add a
    TppDrawText draw command object on the last page using the Report.OnEndPage
    event. You would need to hook into the summary band's afterprint event to
    get the last printing position to be able to correctly position the draw
    command.

    uses
    ppDrwCmd, ppTypes, ppUtils;

    procedure TForm1.ppReport1EndPage(Sender: TObject);
    var
    liHeight: Integer;
    lDrawText: TppDrawText;
    liTop: Integer;
    liWidth: Integer;
    lBitmap: TBitmap;
    begin

    lBitmap := TBitmap.Create;


    liTop := FCurrentPosition;

    lDrawText := TppDrawText.Create(nil);
    lDrawText.Page := ppReport1.Engine.Page;
    lDrawText.Text := 'Some Text';
    lDrawText.Font.Size := 10;
    lDrawText.Font.Name := 'Arial';
    lDrawText.Font.Color := clRed;
    lDrawText.Color := clAqua;
    lDrawText.Left := ppReport1.PrinterSetup.PageDef.mmMarginLeft +
    (ppReport1.PrinterSetup.PageDef.mmPrintableWidth) div 2;

    lBitmap.Canvas.Font := lDrawText.Font;

    liHeight := lBitmap.Canvas.TextHeight(lDrawText.Text);
    liHeight := ppToMMThousandths(liHeight, utScreenPixels, pprtVertical,
    ppReport1.Printer);

    lDrawText.Height := liHeight;

    lDrawText.Top := liTop - liHeight;

    liWidth := lBitmap.Canvas.TextWidth(lDrawText.Text);
    liWidth := ppToMMThousandths(liWidth, utScreenPixels, pprtHorizontal,
    ppReport1.Printer);

    lDrawText.Width := liWidth;

    lBitmap.Free;

    end;

    procedure TForm1.ppSummaryBand1AfterPrint(Sender: TObject);
    begin
    FCurrentPosition := ppReport1.Engine.PrintPosRect.Bottom;
    end;


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.