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

Fixed subreport with dynamic band. How to get space used?

edited November 2004 in Subreports
Hi,

I'm faced with a little problem here. I have a "Fixed style" subreport that
contains a dynamic height detail band. I would like to know if there's any
way to get the space used by the subreport (The sum of the height of all
detail band that printed, not the height of the subreport itself). I tryed
the property SpaceUsed, but it returns the height of the SubReport, not the
height used by the detail bands.

Is there a solution along those lines??

SubReport.Generate;
MyHeight := SubReport.Content.spGeneratedHeight

Or will I need to do it dirty and connect somewhere around the AfterGenerate
event? (And... Would it even work? Didn't try yet! ;) )

And, if it's not too much to ask... (God I know it's gonna be!^_^) I would
like a solution that can work outside of the report printing routine.(Bye
bye AfterGenerate?). I wanna know how much space I'm gonna use up, so I
could give more space to another subreport. Or even move another subreport
from the main report to the subreport with space enough space left.

Hope you'll have some good news for me!


Environment information:
Windows 2000 SP4
Delphi 5 (W/ Update pack 1)
ReportBuilder 6.03 Professional

Ken Bourassa
Analyst - Programmer
Groupe Jean Coutu

Comments

  • edited November 2004

    Consider using a Subreport set to pbChild with a StopPosition assigned to
    limit the page space that it can occupy. Then you can use ShiftRelative on
    the other subreport and it will automatically reposition itself to start
    printing just below the first subreport.





    --
    Nard Moseley
    Digital Metaphors Corporation
    www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited November 2004
    Seems to me it would work... But then again... My problem is a little more
    complicated. I'll try to explain it as well as I can.

    At the moment, I'm building a report that "should" contain only 1
    page(pre-printed labels). There are a lot of "fixed" area. (Where the
    content doesn't change/move) There are 3 areas of different sizes that are
    shared by about 20 subreports (behavior "fixed" at the moment)that may or
    may not print depending on some conditions.

    What I do is
    1. For each subreports that prints I make a list of "area" where it can
    print
    2. I build a list of all the subreports that need to print according to
    the actual situation.
    3. I try to assign all the subreports to an area.(Only 1 subreports by
    area at the moment)

    Now, if the Subreports can't all print on 1 receipt, what I do next depends
    on the "type" I assigned to the subreport.

    The types are
    ForceNewPage : Force the printing of a new page(pre-printed labels)
    BlankPage : Print on a blank 8?X11 label
    Drop : Drop it. Don't print.

    What I would like to be able to is to assign more than 1 subreports to an
    "area", making sure it would completely prints in the current page before
    actually printing it. (I can't afford to generate the whole page over and
    over just to make sure all the subreports fit in their areas, for
    performances reasons).

    As you can see from my subreport type, if the 2nd subreport I try to fit in
    a area doesn't fit, I need to know it before printing for the following
    reasons:

    1. I don't want partial printings there.
    2. I don't want it to spawn over many pages. I will send it to a 8?X11 in
    this case
    3. I may force a new page(Pre-Printed label), or print on a blank 8?X11,
    or even drop it and not print it at all

    Now, is there a way to generate a subreport without generating the whole
    report?
    Is there a way to know how much space a section will use before printing it?
    Is there a faster way to generate a report than the "print" method for
    section size calculation purpose? (It takes about 2 seconds to generate 1
    page with the print method)

    Thanks for your time

    Ken Bourassa
    Analyst - Programmer
    Groupe Jean Coutu



  • edited November 2004

    There is nothing built into the report engine that will help you with this.

    The best approach I can think of would be to write custom code that can
    calculate the amount of space required for each subreport. If the subreport
    layouts are simple with static height bands, then you can just add up the
    heights of the bands. For the detail band, you need to know how many times
    it will print. This requires opening the query and counting the records in
    the query - I think you find that is where most of the overhead occurs.



    --
    Nard Moseley
    Digital Metaphors Corporation
    www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.