g.copies always 1

  1. 4 weeks ago

    Martin F

    Jan 16 Pre-Release Testers, Xojo Pro Kiama, Australia

    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(p)
    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
    End If
    End If

  2. Martin F

    Jan 16 Pre-Release Testers, Xojo Pro Kiama, Australia

    Simpler example same result

    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

    End If

  3. brian f

    Jan 17 Pre-Release Testers, Xojo Pro Chilly California
     
    
     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 
    
  4. Tim P

    Jan 17 Pre-Release Testers feedback://46303

    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

  5. brian f

    Jan 17 Pre-Release Testers, Xojo Pro Chilly California
    Edited 4 weeks ago

    @Tim P 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

    Ah ok it is a 2018R4 problem?

    I'm still on 2018R3

    Thanks for the report Tim

  6. Tim P

    Jan 17 Pre-Release Testers feedback://46303

    Martin is reporting it on 2018r2 as well. The test is simple to do:

    dim ps as new PrinterSetup
    dim g as Graphics = OpenPrinterDialog(ps)
    if g <> nil then
      dim iCopies as Integer = g.Copies
      break
    
    end

    Change copies in the print dialog to anything other than 1.

  7. brian f

    Jan 17 Pre-Release Testers, Xojo Pro Chilly California

    Ah my old eyes missed that part of the OP's post about being on 2018r2 :/

  8. Dave S

    Jan 17 San Diego, California USA

    I seemed to recall that Copies has NEVER worked?

  9. Jeff T

    Jan 17 Midlands of England, Europe

    I seemed to recall that Copies has NEVER worked?

    Me too. Been a problem for so long I gave up even testing it.
    Ditto page ranges

  10. Don L

    Jan 17 Pre-Release Testers, Xojo Pro Florence, South Carolina USA

    @Jeff T Me too. Been a problem for so long I gave up even testing it.

    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.

  11. Paul R

    Jan 17 Pre-Release Testers, Xojo Pro Kirkland, WA

    Isn't this because (on macOS at least), the system takes care of printing multiple copies?

  12. Dave S

    Jan 17 San Diego, California USA

    @Paul R Isn't this because (on macOS at least), the system takes care of printing multiple copies?

    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.

  13. Roger C

    Jan 17 Lewis Center, OH

    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.

  14. Tim P

    Jan 17 Pre-Release Testers feedback://46303

    So it sounds like Paul was correct then. This is good news.

  15. Jürg O

    Jan 17 Pre-Release Testers, Xojo Pro
    Edited 4 weeks ago

    See Feedback Case #50117 (Closed By Design): OpenPrinterDialog / always one copy

    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.

  16. Roger C

    Jan 17 Lewis Center, OH

    So do we still need to provide a loop

    for i As integer = 0 To g.copies-1
       //print
    Next

    Or is that all useless code?

  17. Paul R

    Jan 17 Pre-Release Testers, Xojo Pro Kirkland, WA

    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.

  18. Paul R

    Jan 17 Pre-Release Testers, Xojo Pro Kirkland, WA

    It might also depend on the particular printer driver.

  19. Martin F

    Jan 19 Pre-Release Testers, Xojo Pro Kiama, Australia

    Thanks for the feedback.
    If I try and print from the compiled version multiple copies to pdf or Preview only a single copy appears in the file.

    Would that be the expected behaviour or should it show multiple copies in the file?

  20. Emile S

    Jan 19 Europe (France, Strasbourg)

    Printing in a file, then make duplicates (of this file) at will.

    Printed to paper is a different beast.

or Sign Up to reply!