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

How to use "letter-paper" with ReportBuilder?

edited August 2009 in General
Hello,
I'm trying to figure out how to achieve the following:

The End-User of our application shall be able to design his own personal
"letter paper"-layout (logo, bank-data etc.). It's the same as if you have
preprinted paper, which you are using for printing of invoices, offers etc.
It just should be designed within the software and be combined with the
actual report before printing.

The advantages:
1) the user has a separate place to edit the layout without the ability to
edit the
data-reports
2) he has to do it only once, instead of changing all reports (if each
of them would contain the layout-elements in it)

The requirements:
1) the user shall be able to determine at runtime, if that
letter-paper-layout shall be used / added or not on a case-by-case basis
2) the user shall have the ability to determine, if that layout should be
visible at
- all pages of the data-report
- certain pages of the data-report: only first, only last, first and last
3) the user shall also be able to create a layout, which has two or more
different looking pages, so the first page of the layout is used for the
first page of the data-report; the second page of the layout is used for the
second page of the data-report and so on

So the question is: does ReportBuilder offer this functionality? The
PageStyle looks like the way to go, though I would like to have some kind of
confirmation for that and to see, how to achieve all I need, since I don't
see the possibility for each of the 3 cases somehow.

None of the reporting solutions seems to be able to do that properly, so I
need to know exactly, if that can be accomplished, before I decide what
solution is the right for our application.

Kind regards,
Mark

Comments

  • edited August 2009
    Hi Mark,

    Yes, this is definitely possible using the PageStyle, subreports, and report
    templates.

    1. First you would need your users to create their layout(s) and save them
    as a report template file (.rtm).
    2. Next, create a separate report that contains a PageStyle band sized to
    approximately a single page height. The PageStyle band should contain two
    fixed style subreports also sized to the height of the pagestyle band.
    3. Before the report is previewed, load each layout template (previously
    saved) into each subreport and based on which option your users selects,
    toggle the visibility of each subreport based on the page of the report
    being viewed/printed.

    Below is a simple demo I created that shows how this can be done...

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

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited September 2009
    Hi Nico,
    thank you for the example.

    I'm at a point now, where I'm about to start with this part of my
    application.
    The user can create several reports for let's say invoices and also several
    "letter-paper layouts". Within the application the user can select one of
    the invoice reports and one of the "letter-paper layots" (or noone). After
    the selection I need to put both reports together.

    As far as I see, this needs to be done:
    1) load the invoice template
    2) check, if the invoice report has a PageStyle already (in most cases it
    won't have one)
    3) if a PageStyle does not exist, then I need to add / create one
    4) if a PageStyle does exist, then it could be neccessary to clear it
    /remove all object on it)
    5) if a PageStyle does exist, then it could be neccessary to remove that
    band
    6) once a PageStyle got added after step 2, a sub report needs to be added /
    created on the PageStyle band
    7) load the "letter-paper layout" into the subreport
    8) preview / print report

    1, 7 and 8 shouldn't be a problem, but for 2-6 I would like to ask for help.
    How can I achieve that? Didn't find anything in the RBWiki or here in the
    newsgroup.

    Mark




  • edited September 2009
    Hi Mark,

    Once you load the report you will want to use the template event OnLoadEnd
    to make these changes.
    http://www.digital-metaphors.com/rbWiki/Design/Templates/Using_Template_Events

    2,4 You can check the Report.PageStyle property to determine if there is
    one or not. If there is, you can loop through the Band.Objects list and
    remove all components. An easy way to remove objects is to set their Band
    property to nil (and free them to keep things tidy).

    3. Creating a band is done simply by calling TppBand.Create(); and then
    setting the Band.Report to the current report object.

    uses
    ppBands;

    MyPageStyle := TppPageStyle.Create(Self);
    MyPageStyle.Report := ppReport1;

    5. Removing a band is done by setting the Report property to nil (and
    freeing it).

    6. See the following article on creating subreports in code.

    http://www.digital-metaphors.com/rbWiki/Delphi_Code/Layouts/Create_SubReport_in_Code

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited September 2009
    Hi Nico,
    what changes do you mean, the template OnLoadEnd event should be used for?

    Other than that everything seems to be clear at the moment. I had already
    found out, how to create SubReports in Code, but I didn't come that far,
    since the PageStyle questions weren't clear. I didn't realize, that the
    PageStyle is a band too like others (which had Band in their name ;) ).

    In the end pretty easy way to accomplish that. Now working on other details.

    Thanks for your help!

    Mark

  • edited September 2009
    Hi Mark,

    The changes I'm referring to are the steps you mention in your first post.
    Basically ensuring that you will be performing these steps to manually alter
    the report after the template has been loaded. A good event for that is the
    OnLoadEnd event but it may not be necessary to use it in your case.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2009
    Hi Nico,

    I discovered an issue with this workflow, I think.
    The DetailBand in the MainReport contains a region (stretch := true,
    transparent := true, visible := true). This region contains several
    DBTextFields like "product number", "amount", "price" etc. They all are
    placed next to each other. One of these fields is the "product description"
    and I'm using a DBRichText for it (stretch := true, transparent := true,
    visible := true).

    As long as only the MainReport is loaded / showed in the preview, everything
    is correct. Once I load the "pagestyle-report" as you suggested, the problem
    occurs. The DBRichText "disappears" and the height of each dataset in the
    detailband is adjusted to the height of the components, which left over. The
    DBRichText is visible for a short moment and then disappears. There is no
    rap-code or Delphi-code doing something like that. Once I remove that
    pagestyle-report, the DBRichText is visible again and the height of the
    detailband is different per dataset depending on the content - how it is
    supposed to be.

    If the "stretch" property of the DBRichText is set to false, it remains
    visible (but the height is logicaly not adjusted).
    If I place a variable in the detailband and set the height of that
    DBRichText to a certain value, the DBRichText is visible again and is showed
    with exactly that value, so it looks, that it's height is being set to 0
    under these circumstances.
    Another case where it works: if all the fields in the detailband are palced
    on different regions, which are placed next to each other. At least once the
    DBRichText is placed in it's own region and no other components are in that
    region, it seems to work too.

    I hope you know what I mean and that you can find a solution for the issue.

    Mark

  • edited November 2009
    Hi Mark,

    If possible, please send a simple example I can run on my machine that
    demonstrates this behavior. Send the example in .zip format to
    support@digital-metaphors.com and I'll take a look at it for you.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2009
    Hi Nico,

    I sent you a sample project, where you can reproduce it.

    Mark

This discussion has been closed.