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

DBText Font

edited February 2013 in General
I was wondering if the following is possible. Say there is a ppDBText
component with a Name that is 50 characters long. The font is set to
Arial , 8 pt. If for example the name gets longer than 50 characters,
is there a way to automatically set the font to 7pt for example.

I assume this is not possible on the component, so would this just have
to be done on the Calc Tab?

Comments

  • edited February 2013
    Hi Jeff,

    There is not automatic way to shrink a font to fit in a give space. You
    could do this manually by measuring the text before it is printed to be
    sure it fits in the allotted space.

    The TCanvas.TextWidth routine to measure the text. This may require a
    RAP passthru function.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2013
    You can add OnDrawCommandCreate event (in RAP or in Delphi) for ppDBText
    component.
    In RAP it will be look something like this:

    procedure ppDBTextOnDrawCommandCreate(aDrawCommand: TObject);
    var
    DrawText: TppDrawText;
    begin
    DrawText := aDrawCommand as TppDrawCommand;
    if Length(DrawText.Text) > 50 then
    DrawText.Font.Size := 7;
    end;

This discussion has been closed.