Fit content in table cells (MailMerge)

General TRichView support forum. Please post your questions here
Post Reply
infrax
Posts: 31
Joined: Wed Aug 10, 2011 10:57 am

Fit content in table cells (MailMerge)

Post by infrax »

Hi

I'm doing a mailmerge with tables (fixed cell height and width). The problem occurs when the data(text) is too long to fit in a cell. In this case I should decrement font size until all text fits in.

And I'm doing this in XML first, than I load it in RV and print it with TRVReportHelper.

Any idea how to do this?

First I need to detect that the text is too long. But this can be done only after TRVReportHelper.FormatNextPage or ... I fact I don't know how to do it there either so ... help me out.

Thanks
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

There is no good solution for this problem, because a text size is known only after formatting.
All that I can suggest is loading cell in a separate RVReportHelper, format it, calculate a document width (I can give a code), change font size, calculate a document width again, and so on. Then modify a font size in the main editor.
infrax
Posts: 31
Joined: Wed Aug 10, 2011 10:57 am

Post by infrax »

Yes, something like that was on my mind also.

Can you give me a sample code (how to calculate width and height of formatted text)?

Or is this done like this:
- load cell data in separate RVReportHelper
- call Init -> set width to cell width (- padding)
- call FormatNextPage
- with GetLastPageHeight I get the formatted text height

Thanks
Post Reply