Report with variable Row Height because MultiLine Field

i made a simple report with a multiline textfield in the body part.

how can i output like this: 1 row 3 rows 2 rows 4 rows in body without empty space below?




Sadly it‘s currently impossible. Xojo‘s report engine isn’t able to do that. You can try to emulate some better report output, but this is only a hack. We wrote an xDevMag article about it. xDevMag
As long as Xojo doesn’t fix/rewrite their report engine, you have to work with other tools.

hmm thats silly.
i can try to replace this multiline as single rows.
or with next update maybe its better to use the new pdf class.

Or use something that is in constant development like the Valentina Reports. I only use Valentina and not Valentina Reports.

at the end i made a extra class with 8 methods and some properties that paint a A4 as graphics + the use of .NewPage.
and TextShape is very useful.

You can have a look at this project to see how I’ve done it. Not “Impossible”, just not intuitive.

Sorry Wayne, I’m gonna have to disagree with you. I’ve known your sample project for quite some time, but it doesn’t work flawlessly. For example with a different font size/name. And you can also see that there is always a certain amount of space below the entries.

True, I’ve got an update for 2020R1 that calculates the row height based on the font & size. That demo was just to show it CAN be done.

thank you for this example.

why did this “Body.Height = 20” not appear in autocomplete?
because it was invisible and i not found it i wrote my report self with paint …

Interesting. Would you please share your findings with us? Thank you.

What I’ve done is calculate the height of the description field by changing the Label1.BeforePrinting Event handler to

[code]Var p As Picture = New Picture(4000, 1000) ’ This is only used to calculate the height of a control
Var g As Graphics = p.Graphics
Var h As Integer

me.Text = “”
Body.Height = 20
If self.DataSource.Field(“description”) = “” Then
DescriptionField.Height = 0
// Set the graphics properties of the temporary picture
g.FontName = DescriptionField.TextFont
g.FontUnit = FontUnits.Point
g.FontSize = DescriptionField.TextSize

// Calculate the height of the description field
h = g.TextHeight(self.DataSource.Field(“description”), DescriptionField.Width)
DescriptionField.Height = h

// Set the height of the row to be printed
Body.Height = Body.Height + h
End If

If Len(self.DataSource.Field(“title”)) > 100 Then
// Title’s can only be 1 or two lines
Body.Height = Body.Height + 10
TitleField.Height = 30
End If

DescriptionField.Top = TitleField.Height + TitleField.Top[/code]

So rather than having a fixed size for the long description it is now calculated to fit the text.

if me input Bo… and Tab it not appear.
as you said with 2020R1 its automatic.

Wayne, I replaced the Label1.BeforePrinting Event handler with your code above, but it doesn’t change anything. There is still a large white space below the body.

If you adjust the size of a line in the before or after events the page size & clip rect don’t seem to be recalculated as they probably should be.

The private ticket I submitted in 2018 has now been set to public. If you are interested in fixing this bug and have feedback points left, feel free to add them to the case and save it as a favorite.

<> (Xojo Reports: Wrong Clipping Rect)