printingxojo

Xojo Print Without Printer Dialog


I would like to print directly to an attached label printer without showing the print dialog.

I have searched to see if such a thing is possible but it seems it is not. So, I thought I would ask here in case someone knows a way to do it.


Solution

  • You have to save the Printer SetupString. Then the next time you go to print use that SetupString to initialize the PrinterSetup object. See actual code copied from working project below:

     'Now print the mail barcode
      dim ps as PrinterSetup
      dim page as Graphics
      ps = LabelPrinter  //See below 
      if ps<>nil then
        page = OpenPrinter(ps)
        if page<>nil then
          //send stuff to the printer here
    
    
    
    Public Function LabelPrinter() as PrinterSetup
      if gLabelSetup<>"" then  //gLabelSetup is saved in preferences
        dim ps as new PrinterSetup
        ps.SetupString = gLabelSetup
        return ps
      else
        return nil
      end if
    End Function