NSPrintInfoMBS: print on a specific named printer and without dialog

I’ve seen the example coming with the MBS plugin named NSPrintOperation and the language reference.

I’ve tried with:

Var g As Graphics
Var p As PrinterSetup
p = New PrinterSetup

// clone to NSPrintInfo
dim info as new NSPrintInfoMBS(p.SetupString)

// find out what name second printer has
dim printers() as string = NSPrinterMBS.printerNames
dim printer as NSPrinterMBS = NSPrinterMBS.printerWithName(printers(1))

// now set this printer
info.printer = printer

// and clone back
p.SetupString = info.SetupString

//If p.ShowPageSetupDialog Then
g = p.ShowPrinterDialog

If g <> Nil Then
… print …

but it doesn’t take the second printer (at least on a Mac, on another Mac seems to catch it)
How to setup to print on a specific named printer calling by its name (i.e. OKI) ?

And how to print without the printer dialog ?
In the example is used this code:

dim v as NSViewMBS = TextArea1.NSViewMBS
dim o as NSPrintOperationMBS = NSPrintOperationMBS.printOperationWithView(v)

o.showsPrintPanel = false
o.runOperationModalForWindow(Self)
o = nil
But i don’t understand how to adapt to my needs cause i don’t have a textarea1…

My first question is really simple to solve … :grinning:

dim printer as NSPrinterMBS = NSPrinterMBS.printerWithName(“OKI”)

The second not so simple … at least for now …

The second answer is simpler then the first … :wink:

g = PrinterSetup.OpenPrinter(p)

Well, do you get a NSPrinterMBS object for the printer name?
e.g. walking over list to find first name with OKI inside.
Then put the printer in printer setup.