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

DBText question on autosize or stretching

edited October 2005 in General
Hello,

Background:
I have a subreport that has a group header band and a detail band. (Group
footer and summary band do not have any rb fields in them.)
The group header has 1 row of labels used for titles to rows of fields in
the detail band.
The detail band has 4 rows of regions on it in the detail band. Height of
all 4 regions are set to: 0.1458
Each region has a number of fields on it.
In Region #2, I have approximately 10 fields that are of a type: dbtext.
from left to right on it.
Field #3 is a dbtext field pointing to a description field in my
datapipeline and is left justified, height of 0.1458 and a width of 2.12.
Region #2 is set to shiftrelativeto Region #1. Region #3 is set to
shiftrelative to the Region #3. Region #4 is set to shiftrelative to the
Region #3.


Problem:
Some of the description field contents contain more data than will fit into
the current width.
Do you have any suggestions and possible example codes to assist me?

Thanks for your assistance.

Karen

ReportBuilder Professional 6.03
Delphi 6.0

Comments

  • edited October 2005
    Hi Karen,

    What would you like to happen when you run out of space? You can replace
    each DBText with a DBMemo so that if the width gets too long it will wrap to
    the next line. You could also manually measure each DBText in the line to
    determine whether the text will fit, then adjust the font size accordingly.
    I can help you with both options however if you are trying to export to a
    text file, I do not believe it is possible to shrink the font size.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2005
    Hello Nico,

    In this case, I am using Report Builder directly (not having RB export to a
    text file).

    In Region #2, I did try replacing the dbText field for Description with a
    dbMemo and set the stretch property to true just to see what would happen

    In most cases, it wrapped the description text to the next line and all the
    subsequent regions (Regions #3 and #4) started below Region #2 as I had
    hoped.
    In other cases, I was disappointed because either of these 2 scenarios
    happened:
    #1 - Because the data residing in Description dbMemo field was on a single
    line yet there was a blank line below it.
    #2 - The data residing in Description dbMemo field was on a single line,
    minus 5 characters (I looked in the database to verify whether or not the
    full contents were being displayed).

    So far, I am not finding any consistency with the use of dbmemo as a
    solution to replace the dbtext field in order to display the full contents
    of the description on my reports. I even tried setting the
    forcejustifylastline to see if it would help when I had the result in the
    scenarios described above.


    Your assistance with both methods that you mentioned would be greatly
    appreciated.


    Thanks,

    Karen

  • edited October 2005
    Hi Karen,

    My first suggestion regarding the use of DBMemos would be to test with
    ReportBuilder 9.03. There have been many changes to ReportBuilder since
    version 6.03 inclucing some dealing with memo spacing and pagination. It's
    probably worth a try.

    As far as the second option (shrinking the font). You would first retrieve
    the text from your database and measure it using the TCanvas.TextWidth
    method. (An easy way to get access to a TCanvas is to create a local
    TBitmap). Once you calculate the text width, you can compare it to the
    width of the DBText component and begin shrinking the font until the width
    is sufficient.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2005
    Hello Nico,

    Thanks for both tips (using RB 9.03 and shrinking the font).

    In regard to your second option to shrink the font, do you have an example
    project or sample code that I could follow in how to do this?

    Thanks,

    Karen




  • edited October 2005
    Hi Karen,

    Sorry, I meant to give you this example in my last post :).

    http://www.digital-metaphors.com/tips/AutoFontSize.zip


    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2005
    Nico,

    Thank you for the example code/project.

    When I ran it, I rec'd an AV error. Tracing it led me to:

    procedure TppProducer.PublishReport;
    begin
    FPublisher.Publish;
    end;

    Error: Cannot generate report.
    Access violation at address 4BE3C3B6 in module 'IDAPI32.DLL'. Read of
    address 0000004A.

    What do I need to do in order to run it successfully?

    Thanks,

    Karen





  • edited October 2005
    Hi Karen,

    I'm sorry but I am unable to test the examples I send with older versions of
    ReportBuilder.

    You may be getting this error when trying to access the printer object. In
    the example this is an easy way to get a hold of a TCanvas object. You
    might try creating a TBitmap object and use the Canvas property of that to
    measure the text. The basic idea is to keep looping and measuring the text
    while shrinking the font until it fits in the alloted space.

    --
    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.