Report from Listbox: a lot of blank space!

Hello XOJOers!

I have a Question About XOJO Reports. I’ve build a tool with a custom listbox that allows it to be used as a RecordSet for printing Reports. This was done as in the example delivered with Xojo. When printing the example from XOJO it only prints the data it has, and then stops. This is what we Need and want. However, with my own report and listbox it Always prints a lot of empty space underneath the Body.

The Report has a Header, a Body and a Footer. No Page Headers and Footers exist. The Code is done exactly like the example, and still it gives us a lot of White space, but not in the example. How could this be? The Code is the same, except for an Event handler which enabled the in-field editing.

This is the second day Tackling this issue, and I still don’t have a clue. Does anyone know what the issue could be?

Without looking at your code the only thing I can think is that maybe an EOL or CR is added somehow.
Can you share the part of the code responsible for this?

[quote=473457:@Alberto DePoo]Without looking at your code the only thing I can think is that maybe an EOL or CR is added somehow.
Can you share the part of the code responsible for this?[/quote]

Thank you for responding. Of Course I can. The Code to print is attached to a button Event handler and Looks like this.

[code] Dim ps As New PrinterSetup

Dim rpt As New report_cash
Dim g As Graphics

ps.MaxHorizontalResolution = -1
ps.MaxVerticalResolution = -1

If ps.PageSetupDialog Then

g = OpenPrinterDialog(ps, Nil)
If g <> Nil Then
  If rpt.Run(wnd_quittung.list_quittung, ps) Then
    rpt.Document.Print(g)
  End If
End If

End If[/code]

I didn’t know if you wanted to see the Code from the custom listbox, but this is the EOF Method of the Custom Listbox

If mRow > Self.ListCount-1 Then Return True Else Return False End If

If you print two “Test” lines, is the spacing repeated?
Have you accidentally changed the height of one of the header/body/footers in the inspector?

[quote=473462:@]If you print two “Test” lines, is the spacing repeated?
Have you accidentally changed the height of one of the header/body/footers in the inspector?[/quote]
How can I print two test lines? I’ve Always tried to print without some form of a recordSet, this didn’t work though.

The height of pageHeader is 60mm, The Body row 6, and pageFooter 80. They visually look correct.

ps.MaxHorizontalResolution = -1 ps.MaxVerticalResolution = -1

looks to be causing the issue, if you remove that does the problem go away?

[quote=473466:@] ps.MaxHorizontalResolution = -1 ps.MaxVerticalResolution = -1

looks to be causing the issue, if you remove that does the problem go away?[/quote]
Sadly, if I remove it it still has the huge space. It doesn’t seem to solve the issue. Removing it does reduce the Quality though.

Hmm, if you change the example project in Printing and Reporting>Reporting>ListBoxReport do you see the issue?

In MainWindow>PrintPreviewButton>Action replace the code with:

[code]Var ps As New PrinterSetup

Var rpt As New NameReport
If rpt.Run(PrintableListBox, ps) Then
If rpt.Document <> Nil Then

Dim g As graphics
g = OpenPrinterDialog(ps, Nil)
rpt.Document.Print(g)
'Var rptWindow As New ReportWindow
'rptWindow.RptDoc = rpt.Document
'rptWindow.Show

End If
End If[/code]

[quote=473470:@]Var ps As New PrinterSetup

Var rpt As New NameReport
If rpt.Run(PrintableListBox, ps) Then
If rpt.Document <> Nil Then

Dim g As graphics
g = OpenPrinterDialog(ps, Nil)
rpt.Document.Print(g)
'Var rptWindow As New ReportWindow
'rptWindow.RptDoc = rpt.Document
'rptWindow.Show

End If
End If[/quote]
Just to make sure, you want to test if my ListBox does work in the example Project? They are except for the Resolution Definition exactly the same Code.

To me it looks like the page “size” is set to Letter (or the European equivalent). May I ask what paper size you chose?

No, just open the example project and replace the code I posted then run it and point it at your receipt printer. This is just to make sure its not a problem with paper height etc.

The width of the paper is defined in Xojo as 80mm (Receipt Paper). It is a receipt Printer. The size in the Printer Setup screen is “Roll Paper 80 x 297 mm”. However, this also works with the example.

It works like expected and only prints the values.

Is the receipt printer the default printer?

What happens if you drop the line

 If ps.PageSetupDialog Then

and associated endif from your code?

[quote=473477:@]Is the receipt printer the default printer?

What happens if you drop the line

 If ps.PageSetupDialog Then

and associated endif from your code?[/quote]
The receipt Printer is not Always the Default Printer. We can also print invoices, which are on normal A4 paper. But, I tried removing the Dialog. It doesn’t solve the issue. The blank space is still there.

I tried the listbox in the example, and there it seems to work. But when I compare the Code it is really just the same.

Edit:
I’ve build in the Preview Window from the example. This also Shows the blank space.

Can you lay down a piece of your invoice paper next to the long receipt with the space and see if one is as long as the other?

If you run this do you see the problem?

[code]Var ps As New PrinterSetup

Var rpt As New NameReport
Dim g As graphics

'ps.MaxHorizontalResolution = -1
'ps.MaxVerticalResolution = -1

'Call ps.PageSetupDialog
g = OpenPrinterDialog(ps, Nil)

If rpt.Run(PrintableListBox, ps) Then
If rpt.Document <> Nil Then

rpt.Document.Print(g)

Var rptWindow As New ReportWindow
rptWindow.RptDoc = rpt.Document
rptWindow.Show

End If
End If[/code]

[quote=473480:@]Can you lay down a piece of your invoice paper next to the long receipt with the space and see if one is as long as the other?

If you run this do you see the problem?

[code]Var ps As New PrinterSetup

Var rpt As New NameReport
Dim g As graphics

'ps.MaxHorizontalResolution = -1
'ps.MaxVerticalResolution = -1

'Call ps.PageSetupDialog
g = OpenPrinterDialog(ps, Nil)

If rpt.Run(PrintableListBox, ps) Then
If rpt.Document <> Nil Then

rpt.Document.Print(g)

Var rptWindow As New ReportWindow
rptWindow.RptDoc = rpt.Document
rptWindow.Show

End If
End If[/code][/quote]

The receipt is Always just a bit short of the A4 invoice paper. It could be the issue, but why is it working with the example? Even if I use my ListBox there.

Yes, it does Show the issue in the preview and when printed. I pick the same paper size in the Example. and it still works how it should!

If you remove all rows from the example except two rows and run the example what do you see, a big gap?

The example has no gap at all, even with multiple rows. When I run the example with 2 rows it only prints those 2 rows and then cuts of, how I Need it to be in my Project. I edited the example and entered my ListBox and updated the fields in the report Editor. It still has no gap. (And that’s good).

I just can’t seem to get it that way in my Project.

What OS? Possible printer driver problems? Would be great to dump the print settings values you got from the driver for inspection. I also never saw Xojo reports working as expected, and that’s why many of us wrote their own solutions tired of waiting for. Bob even sells his own complete set, maybe another bug?

This is a continuous feeding printer, designed for infinite printing. Not sure if a paper size fits here (except paper width, not length).