Selecting the printer to use (not the default printer/Windows 10), without asking the user.
Sending text to a specific printer (not the default printer/Windows 10), without asking the user, not even once.
Dear Friends.
I am a user since RealStudio (2011). A few years ago I upgraded to xojo, but I didn’t use it because I didn’t understand the new interface well or know the new commands, and that’s how time went by.
Now I’m finally updating my old programs to Xojo 2022.r3.2 and I see sadly that my software requires a lot of changes, I’m working on it.
The biggest problem I have, is trying to send text to a printer different to the windows default printer.
My computer has 2 printers, one is to print invoices (Brother/InkJet/Letter sized) from a billing software I bought (this is the default printer in Windows 10), and the other is a POS printer (Bixolon/thermal printer for tickets) to print just that tickets, and this is the one that my program should use (this is configured in Windows but it’s not the default printer, and in fact no other program uses it, it’s just for my program).
The point is that the two printers are already registered in Windows, I have the “settings” of the Bixolon printer saved in a small database, and when I need to print a ticket, my program searches and loads the “settings”, it builds the ticket, and sends it to this printer. I don’t need to ask the user, nor do I need to select the printer they want to use, that is always fixed.
The specific problem is that although my program opens the file with the settings and assigns them, when it sends to print they come out on the Brother printer, not on the Bixolon! It’s as if a couldn’t identify it, it just sends it to the default printer. Before, it did print to the correct printer with no problems, but it no longer does so.
I would like to know what is wrong, because it has been working well for years, and it no longer does.
Here are the settings that I have saved:
DoNotAlterThis=SetupString.2 ActualHorizontalResolution=72 ActualVerticalResolution=72 MaxHorizontalResolution=72 MaxVerticalResolution=72 MarginLeft=0 MarginRight=0 MarginTop=0 MarginBottom=0 MinMarginLeft=0 MinMarginRight=0 MinMarginTop=0 MinMarginBottom=0 PageSetupFlags=10 DevModeStructureSizePS=936 DevModeStructurePS=BIXOLON SRP-F310
And this is the program that assigns these settings to the printer:
Dim Settings as String // Settings will be used for keeping the printer’s settings
Dim pageSetup As PrinterSetup
pageSetup = New PrinterSetup
// Then I access my database, and store the printer settings (listed before) in the “settings” variable
Msgbox “The settings from the database are:”+chr(13)+settings // This is just to verify that the settings are complete and correctly accessed.
pageSetup.SetupString = settings // Here I assign the setting to the printer (including the printer’s name as named by Windows)
Dim g as Graphics
g = OpenPrinter(pagesetup)
g.DrawString ("Hello world”,0,0) … // Just normal printing row by row
…
…
…
Do you see something wrong here? Any suggestion will be very welcome!
Best regards!