Printer Settings on Mac OS X

Hi, I am doing a software and I’m trying to save the settings of the selected printer are taken OpenPrinterDialog() and save to a file.

Dim g As Graphics
    Dim p As PrinterSetup
    p = New PrinterSetup
    If p.PageSetupDialog Then
      g = OpenPrinterDialog(p)
      If g <> Nil Then
        g.DrawString("Printer", 50, 50)
        
        Dim f As FolderItem
        Dim stream As BinaryStream
        f = dir.Child("setting.bin")
        If f <> Nil Then
          stream = BinaryStream.Create(f, True)
          stream.Write(p.SetupString)
          stream.Close
          
        End If
      End If
    End If

But I take the printer settings set to the default Mac OS X and not the one selected with OpenPrinterDialog(), why?

Before printing the next time, set the Setupstring to the stored value like this

p.SetupString = StoredSetupString 'Read from stream or variable in your software

  Dim g As Graphics
  Dim p As PrinterSetup
  p = New PrinterSetup
  
  if ps.Len <> 0 then
    p.SetupString = ps  ' ps = stored printer setup string
  end if
  
  If p.PageSetupDialog Then
    ps = p.SetupString
    
    g = OpenPrinterDialog(p)
    If g <> Nil Then
      g.DrawString("Printer", 50, 50)
      
       Dim f As FolderItem
       Dim stream As BinaryStream
       f = dir.Child("setting.bin")
       If f <> Nil Then
       stream = BinaryStream.Create(f, True)
       stream.Write(ps)
       stream.Close
       
      End If
    End If
  End If

I tried but it does not work. I also tried to put in a p.SetupString memoryblock to see if it was a coding problem, but nothing. I created a new project to test if anything is guilty of something in the software, but when I go to print, it always print with the default printer. What can I try?

Hi,

download and try the following example project. It shows what to do.

link to project

I tried but it does not work. It prints width the printer of Default on Mac. I have to print in silent mode. In Windows it print well, but on Mac no.

Oh, sorry,
now I got it. You want to draw with another printer instead of the default printer.

I haven’t done this before but found the following thread,
http://www.monkeybreadsoftware.eu/listarchive-realbasic-nug/2004-11-12-6.shtml

Perhaps you can set the printer with a script. Have no experience with that. Perhaps anotherone can help out.

Any progress on this? It must be a common problem and one Xojo ought to be able to resolve without resorting to Apple scripts.

I have two printers on an iMac and in the early stages of building my first Xojo app on OS X10.10.3. I only use the non-default printer for my Xojo app. I need to save its printer settings and automatically load them on start-up. My client will not appreciate having to set up the printer every time my app is started.

[quote=200606:@Keith Laws]Any progress on this? It must be a common problem and one Xojo ought to be able to resolve without resorting to Apple scripts.

I have two printers on an iMac and in the early stages of building my first Xojo app on OS X10.10.3. I only use the non-default printer for my Xojo app. I need to save its printer settings and automatically load them on start-up. My client will not appreciate having to set up the printer every time my app is started.[/quote]

I can think of one solution : use a helper app which targets the second printer, so after setting it up once it will be able to print silently. Then use IPCSocket to send the data from the main app to the helper. In terms of UI, if done well, to the user it can be made quite transparent.