[fpc-pascal] FPReport: Split text across two or more pages

Pique7 pique7 at gmx.net
Tue Jan 2 17:46:04 CET 2024


On Tue, 2 Jan 2024 00:02:35 +0100 (CET)
Michael Van Canneyt via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:

>
>
> On Mon, 1 Jan 2024, Pique7 via fpc-pascal wrote:
>
> > Hello everyone,
> >
> > I have already asked this and related questions in the Lazarus Forum.
> >
> > I want to improve FPReport in order to use it for my project - if possible.
> > Some features are missing for this, e.g. automatic splitting of text across two or more pages.
> >
> > As far as I can judge, the current development status of FPReport does not really allow me to extend it without modifying the original classes.
>
> Why do you think so ?

Thanks for your reply. I am not sure whether I have defined the problem correctly from my point of view.
I have tried both FPReport and LazReport. LazReport is able to create page breaks within a band automatically (though not always correctly calculated). This is traceable by viewing the source code of LazReport. I haven't found anything similar in the source code of FPReport and thus considered to implement it myself. But I haven't found a straightforward solution.

>
> > What approach do you suggest? Would this be feasible/reasonable at all? I ask this because I am new to Lazarus and FPC. I come from Delphi 2007 ...
>
> If you ask me, it's perfectly doable without any changes.
>
> There is a demo that shows how to print a text by splitting it in lines, and
> simply printing a band per line. That will have the same effect as what you
> seem to need.  Basically, it means using a TStringList as a data source
> for a (sub)band instead of using it as the text of a single memo.

Unfortunately I couldn't find the demo program you mention. I know the fcl demos in "source\packages\fcl-report\demos". Admittedly I haven't examined every single unit yet. Most of the demo reports get the data from a TStringList. Is it this what is meant?

>
> What you may need to do is to split the text "correctly" over the lines of the
> TStringList, but that should be easily doable. All you need is a function to
> calculate the length of the text.
>
> I think this is perfectly doable without any changes to the original code.

Okay, probably you're right and I think I understand the basic idea but I still don't know how to transfer it to my case. I have a table with several columns containing multiline text. The data comes from a TDataSet descendent. If one the cells (Memo) content is to large to fit on the current page, the whole band should be split at the correct position and continued on the next page, e.g.:

    [PAGE 1 - DATABAND 1 (bottom of page)]
    COL 1-1      COL 2-1
    COL 1-2      COL 2-2
    COL 1-3      COL 2-3

    [PAGE 2 - DATABAND 1 (continued)]
    COL 1-4      COL 2-4
    COL 1-5

I also have one report with one column containing richtext (RTF). I doubt that the TStringList solution will be helpful in this case.

So in a nutshell, I think I need a function like "Continue (data) band on the next page if remaining space is insufficient".
If you still think your suggested approach is suitable, please let me know. Maybe it is obvious, but at the moment it seems that I don't make any progress.

>
> Michael.
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


More information about the fpc-pascal mailing list