Print without dialog

  1. 2 weeks ago

    Hello,
    i want to print a file without dialog on a standard printer.
    My code is from the examples printer -> PrintText

    Dim ps As New PrinterSetup
    If ps.PageSetupDialog Then
      Dim page As Graphics
      page = OpenPrinterDialog(ps)
      If page <> Nil Then
        ' Draw text on page 1 with 1 inch left/top margin
        Dim leftMargin As Double = ps.HorizontalResolution
        Dim topMargin As Double = ps.VerticalResolution
        page.TextSize = Val(FontPopup.Text)
        page.DrawString(TextArea1.Text, leftMargin, topMargin, ps.Width - leftMargin * 2)
      End If
    End If

    What can i do to disable both dialogs?

  2. Jean-Yves P

    Jul 5 Pre-Release Testers, Xojo Pro Europe (France, Besançon)

    use openprinter instead of openprinterdialog

    Dim ps As New PrinterSetup
    If ps.PageSetupDialog Then
      Dim g As Graphics
      g = OpenPrinter(ps)
      If g <> Nil Then
        // Draw text 1 inch across and 1 inch down
        g.DrawString("Hello World", ps.HorizontalResolution, ps.VerticalResolution)
      End If
    End If
  3. I want to print a file WITHOUT dialog on a standard printer.

    With this code:

    Dim ps As New PrinterSetup
    'If ps.PageSetupDialog Then
    Dim g As Graphics
    g = OpenPrinter(ps)
    If g <> Nil Then
      // Draw text 1 inch across and 1 inch down
      g.DrawString("Hello World", ps.HorizontalResolution, ps.VerticalResolution)
    End If
    'End If

    only the dialog for the printer appears. But the standardprinter is activated.
    How can i print without clicking on the standard printer?
    Maybe the main error is Linux? Xojo is very buggy on Linux.

  4. Jean-Yves P

    Jul 5 Pre-Release Testers, Xojo Pro Europe (France, Besançon)
    Edited 2 weeks ago

    this :

    Dim ps As New PrinterSetup
    Dim g As Graphics
    g = OpenPrinter(ps)
    If g <> Nil Then
      // Draw text 1 inch across and 1 inch down
      g.DrawString("Hello World", ps.HorizontalResolution, ps.VerticalResolution)
    End If

    works fine on a mac. prints hello world without any dialog. I just tested it on an empty project.
    so yes it must be a linux-xojo problem ?

  5. Thats unbelievable! That doen't work on Linux. To write a simple program takes time for days, or is impossible....

  6. Emile S

    Jul 5 Europe (France, Strasbourg)

    Hi Peter,

    there is a Linux channel to ask questions…

or Sign Up to reply!