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

Adding Property To DBText

edited November 2005 in General
Morning,

On a lot of my reports I have a problem with printing some db fields.
In many cases I'm printing on a form that has defined a fixed width
for each field. Unfortunately sometimes the data exceeds this width.
When this happens, since the field has a fixed width I can't use
autosize so some of the characters are dropped. My solution to this
has been to write a little routine that adjusts the font during
printing - thus fitting more characters into the space available.
Generally this means that everyone will get printed.

I'm now looking at using the routine in dozens of reports on hundreds
of fields and it has occurred to me that rather then adding code to
each field I should enhance the dbtext and label components
themselves. I'm thinking that I should added a new property, Adj Font
to Fit, to the dbtext and label fields. However, I took a look at
the code for the dbtext field and was a little intimidated.

So two questions - 1st - have I missed something already present in
the components that will accomplish what I'm trying to do?

and 2nd - can you give me a hint where I should place my code.

Thanks

Craig

Comments

  • edited November 2005
    Hi Craig,

    1. No, unfortunately there is no built-in functionality to shrink the font
    of a DBText or Label in ReportBuilder.

    2. I strongly recommend that you do not try to alter the ReportBuilder
    source to add this functionality for the following reasons.

    - These changes will not be recognized at design time unless every one of
    the ReportBuilder packages was re-built and re-installed to the Delphi IDE.
    Therefor you will be forced to implement thes new property in code for every
    DBText or label you place on your reports. The difference between this and
    adding a simple line of code that calls a static helper function that
    performs the same task is minimal.

    - Making this change will require you to change the Interface section of
    the TppDBText and TppLabel classes. This will render RAP useless due to the
    fact that we do not ship the source to this section of ReportBuilder.

    As I mentioned above, I would recommend creating a simple static function
    that takes the DBText or Label and text string as parameters and returns a
    font size keeping everything in one line.

    DBText1.Font.Size := MyUtils.AdjFontToFit(DBText1,
    ppReport1.DataPipeline['CompanyName']);

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2005
    Point taken .

    Any thoughts on which event, format, gettext or print, would be best
    place for the call?

    Craig

    On Tue, 1 Nov 2005 08:57:35 -0700, "Nico Cizik \(Digital Metaphors\)"
  • edited November 2005
    Hi Craig,

    Try adding it to the OnGetText event.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.