Selecting printer without asking user

Wrong.

Yes. They aren’t.


The main reason of this fails, as already said, was that he was trying to use the text part of the config and was discarding or corrupting the binary attached part of the contents.

That’s why the first line of the config says:

DoNotAlterThis=…

Thank you Joseph for your message! I´ll verify that this windows option is NOT selected. In many occasions, it is not “the best” idea to let windows decide :slight_smile: Best regards.

You are right Stefan, thank you very much! Is a good idea to write and run in the machine, a little program that opens the dialog to let you choose the desired printer, and generates the settings data, then encode it and save it. This way I could be sure that the settings are “for that machine”, they are current and fresh, that they will work for sure, and will be keepen for later use. :slight_smile:

Jose never said he edited the setupstring, only that he saved it, which worked for awhile until it got corrupted somehow and now he needs to re-save it. Christian was the one who mentioned the ability to edit a setupstring, but we know he wasn’t talking about modifying it directly, but through the appropriate declares.

Sure, just truncated it.

You’re right Tim, I’ve never modified it, but I found that after setting the data, then writing it to the database, then reading it back and saving it in a string variable to display it in a message, the data was truncated! (Incomplete). After doing this same process, but encoding the information with EncodeBase64 before saving it, this does not happen! and I get complete information every time (decoding it of course), that is the solution!!!

I already verified this in my little test program, now I will integrate it into the main program.

You were right from the start, I needed to encode it, regardless of preventing a user from trying to modify it (that was never the problem), but the data was truncated when assigning it to the variable as just a String! That doesn’t happen when encoding/decoding the data.

I really appreciate your help, thanks for it! I am indebted to you!

Guys, just to tell you that it’s working as expected! Thank you very much for your valuable help to achieve it!

Just one last thought though, the RealStudio platform used to send the font code for the printer to use it, which was a clean and very readable font (on BIOLON printers it was the A11 font and used to work with the g.TextFont=" FontA11"). But now it doesn’t work in Xojo that way, now Xojo DRAWS the letters directly on the graphic object, so the letter must exist on the computer (no longer on the printer), I had to google fonts looking for a monospaced font (to format the printed information), then I had to install the font in windows, so when printing now you have to select that font in windows to send the drawed text to the printer. Unfortunately these fonts are not as clean and legible as the printer made them, but they can be used. At least it’s no longer a problem to send codes to the printer. :slight_smile:

Best regards to all of you!

to add to this topic, does someone (among @Christian_Schmitz !?) know where we can find a definition of what’s inside a setupstring, at byte level ? thanks.

On Windows. It’s just the DEVMODE structure

But we got a class for this: WindowsDeviceModeMBS class.

That allows you to set properties and get setup string in and out.

I know that you have a class for that Christian :slight_smile:
I just don’t understand why such a simple string of bytes has such a difficult to find information on it !
at least for the mac.

edit: is it related to the NSPrintInfo ?

PrinterSetup on macOS is a serialized NSPrintInfo, so you can use our NSPrintInfoMBS class to work on it.

In general, please avoid just messing up the string yourself.

1 Like