For Next draw some more lines (bkgnd colors)

Hi all,

this will be hard to explain for me, but I try.

In a For …/… Next lop, I draw some header, core date and footer.

Header and core data have background colors.

header background color and footer (default background color: white) appears correctly, as I code them.

But, in the last page, when the core data does not fill it (only a bunch of lines on my two testing text files), the last line with text are followed by empty lines of background color (the same color used by the last line with text).

Here is an example of the generated pdf.

Go directly to the last page and you will see line 185 with a blue background and the last part of the page filled with the same nice blue background. If I remove the entry numbered 185 (and then have the entry 184 with a light yellow background), the empty background will have its light yellow background color.

As you understand between the lines, the printing stops when the loop prints the last line of text; the for next loop looks like (pseudo code):

[code]For LoopIdx = 0 to ListBox # Of Rows (-1 because 0-Based)
If a variable is 1 (for line #1):
print the header (with a light green color background and a line of text - the ListBox heading strings)
end if

print the contents of Row(LoopIdx) using a 2 colors background (light yellow and light blue)

If the number of printed lines fills the page
print the footer (without a color background; the text is the current date and time, centered)
reset some variables
issue a next page
end if
If UserCancelled Then Exit
I print a last footer after the loop without background color. (same footer used above in the loop)

Why do I get those extra background colored lines ?

PS: depending on the number of lines, I can have just two lines in excess and the remainding of the page is white.

OS X 10.10.2
Xojo 2014r3.2

Its hard to understand what you are doing from the post.
My guess from looking at the PDF is that the code you are using to draw a row in colour, is actually drawing something that is much taller than a row.
It extends into the footer area too.

So instead of drawing

You are drawing
XXXXXXX YYYYYYY – the Y rows cover the second line of the X row

Hi Jeff,

thank you for your kind answer.

Yes, you are right, the explanation is not in my mother language (French).

Ohhhhh. Some idea comes to mind from your words: “the code you are using to draw a row in colour, is actually drawing something that is much taller than a row”.

It is possible in theory, but since I set the tall value for the background colors to the text tall value, I do not think so.
The idea was:
Text line height: 20 pixels
Background Color printing ‘line’ (in my mind) is 20 pixels, but:
line 1 tall is 35 pixels, (is or can be: I try to explain to myself why there is a problem)
line 2 tall is also 35 pixels, but started at Y = 20 so I do not see the error.

In that case, in the last line, I would have a maximum of 15 pixels ‘too much’… and so I see an error. But this is probably not the case: I have more than one colored background lines…

BTW: the printed data comes from a ListBox, but only the texts are taken, the code does not print the ListBox by itself (how ?).

At this stage, I can add some code to load the text file displayed in the ListBox and print the text file above a two colored background.

Talking about that: I may print the colored background BEFORE printing the black text (in a different For …/… Next loop). The only bad thing is in the last page: I will have the page ful of alternate background colors, and some without any text. But this wil not be considered as an error unlike the current behavior who display many lines with the same color (but sometimes the light blue is used while sometimes the light yellow is used: it depends on the background color of the last line of text: odd or even !).

Thank you for the ideas: I will investigate these this afternoon.

Have a nice Sunday.