PrinterSetup doesn’t keep the printer selection

This is a long standing problem (see <https://xojo.com/issue/23157>) .
The printer setup is keeping the printer setting, but NOT the printer itself. The settings are correct but the printing goes to the DEFAULT printer.

That means that, before printing the labels they ALWAYS have to re-select the printer.

The only workaround I found is to define the label printer as default…
Not convenient and not acceptable as they have multiple label printers.

Does someone have a solution ?

I believe that Xojo needs an upgrade to their function set for printing. It’s horrible.
We need to have ways of programmatically, without dialogs, do:

Read printer names,
Select one like a SelectPrinter(printerName As String) As Printer (The printer object has a full set of the current printer properties, gets a graphics object, have a page setup object; or you’ll get a Nil due to some error like invalid printer name),
You can change and set printer properties back,
Do the print job.

This way we can do the printing works, freely, without dialogs, if needed.

I don’t understand how such a basic question has been left unanswered for so many years !
There are dozens of posts on the forum and there’s not a single Xojo solution.

Come on Xojo !

https://forum.xojo.com/conversation/post/313714

Anything depending on shell and external agents which can absent or incompatible is unacceptable. We need native solutions. And the problem goes much deeper than just a collection of printer names, the entire current print system needs an overhaul.

Thanks @Jean-Yves Pochez , but I agree with Rick.
I found a solution using MBS, which is not native but don’t rely on shells.

If you want to avoid shell usage for a mac app store submission, I’m pretty sure apple will not allow to change the printer from the app…

I’m pretty sure Apple would not forget to give access to basic things to devs.

https://developer.apple.com/documentation/appkit/nsprintinfo/1524495-printer

https://developer.apple.com/documentation/appkit/nsprinter

https://developer.apple.com/documentation/appkit/nsprintinfo/1529413-printsettings

etc…

you can use these nsprinter things with xojo macoslib …
what I’m not sure is if you’re allowed to change printer from your app

An overhauled Xojo print system as I proposed can.

We have a solution for MBS Xojo Plugins:

[code]Dim npe As New PrinterSetup

// fill it with new printer info with given printer and paper
Dim n As NSPrintInfoMBS = New NSPrintInfoMBS
n.printer = NSPrinterMBS.defaultPrinter
n.paperName = “A4”

npe.SetupString = n.SetupString

call npe.pageSetupDialog[/code]