I am having trouble printing multiple copies of an output where g.copies is always 1.
I went to the examples and made the following change for g.nextpage but as copies is always 1 the loop doesn’t work.
I’m using - 2108 R2
Dim g As Graphics
Dim p As PrinterSetup
p = New PrinterSetup
If p.PageSetupDialog Then
g = OpenPrinterDialog§
If g <> Nil Then
for i as integer = 1 to g.Copies
Dim hDPI As Double = p.HorizontalResolution
Dim vDPI As Double = p.VerticalResolution
Dim pageWidth As Double = p.PageWidth
Dim pageHeight As Double = p.PageHeight
g.TextFont = "Arial"
g.TextSize = 9
// Width and height of label in inches
Dim labelWidth As Double = WidthField.Text.Val
Dim labelHeight As Double = HeightField.Text.Val
// Width and height of label in page points
Dim labelPageWidth As Double = hDPI * labelWidth
Dim labelPageHeight As Double = vDPI * labelHeight
// Draw as many labels as fit into the size of the page
For x As Integer = 1 To pageWidth Step labelPageWidth
For y As Integer = 1 To pageHeight Step labelPageHeight
If (y + labelPageHeight) < pageHeight And _
(x + labelPageWidth) < pageWidth Then
g.DrawString(LabelArea.Text, x, y)
End If
Next
Next
if g.Copies > 1 then
g.NextPage
end if
next i
If ps.PageSetupDialog Then
Dim g As Graphics
g = OpenPrinterDialog(ps, Nil)
If g <> Nil Then
for i as integer = 1 to g.Copies
// if the report runs successfully
If rpt.Run(orders, ps) Then
rpt.Document.Print(g)
End If
if g.copies > 1 then
g.NextPage
end if
next i
End If
For i as Integer = 0 to g.Copies -1
//YOUR PRINTING METHOD
If i < g.Copies -1 Then
// kicks out a page and starts a new one
g.nextpage
End If
Next
//Make g Nill to ensure no blank pages
g = Nil
The issue is that no matter what the user enters on the print dialog, g.Copies is always reporting 1. I am seeing this and can confirm the behavior happens with Xojo 2018r4, macOS 10.14.2
Consider this an amen from the congregation, but I ran into this with 2014, R2.1. I remember others at the time lamenting the same issue. So, it’s at least that old.
I think that is more precieved than actual… I would think that any app (Apple or otherwise) would basically do the same as what Brian illustrated… And if it were baked into macOS directly, than it should work automagically for Xojo too.
I ran the latest version of my main app with Xojo 2018.4 breaking on
g.copies
It was always 1 as reported by others. Also tried with Xojo 2017.3. Same result
Ran the compiled version of my app which is currently on the web site. Can’t remember whether it was compiled with 2018.4 or 2018.3, but it was one of the latest versions.
When I chose PRINT and selected 2 pages, 2 pages were printed. IOW, this seems to not display correctly in the debugger, but functions correctly in a compiled app.
[quote]Joe Ranieri on 30 Mar 2018
This case has been closed because the behavior described is not a bug. macOS will take care of respecting the number of copies the user requested and the application only needs to provide a single copy.[/quote]
That loop will take care of platforms where the system doesn’t take care of multiple copies. However, I’m not sure what the situation is with Windows and flavors of Linux.