I am trying to memorize and bring back printer settings with the same value as used before.
From what I read at http://documentation.xojo.com/index.php/PrinterSetup.PageSetupDialog it should be possible to use a saved setupstring tofeed the printer dialog previous setups :
app.printer = new PrinterSetup
app.printer.SetupString = SetupStr
If app.printer.PageSetupDialog Then
Setupstring = app.printer.Setupstring
SetupStr is the previous setup, where margins are set.
Unfortunately, it does not seem like pageSetupDialog takes into account the settings stored in app.printer.
Has anybody tried this before ?
In your If statement you are setting Setupstring to the app.printer.setupstring rather than SetupStr.
Is this right?
I am setting the value of the pageSetup app.printer property SetupString to the previously saved SetupStr. According to the LR, if the pageSetup has already been set, that should reflect in the PageSetupDialog.
Sorry, Michel, I think you misunderstood me.
Your code looks like Setupstring = Setupstring
This will mean that SetupStr is never initialised.
@Michel Bujardet - make sure you use hex or base64 Encoding when you store the setup string. It may include bytes that cause problems when reading or writing.
You are right. It now works perfectly, after storing the setupstring encoded Base 64.
Thank you Greg
Be careful, you’ll need to make sure the printer you’re restoring the setup string to is the same one you saved the string from. I abandoned this a long time ago because it got very complicated trying to find a way to make sure it was the same printer. Restoring to a different printer leads to a crash - or at least it did back in 2016 R3, maybe it’s been fixed since then.