Saving and reloading printer settings

I am a newbie here and trying to create my first complete program. I am doing OK … but currently my hurtle is saving and reloading Printer setting. I copied the code from the Xojo manual. and could use some help . Is the manual wrong or am I doing something wrong?
Edit : I am using linux Mint LMDE

 

Just worked on this yesterday and got very odd results until I encoded the Settings string like:

’ saving
Var pageSetup As New PrinterSetup
Var encodedText As String = EncodeBase64(pageSetup.Settings, 0)

’ loading
Var decodedText As String = DecodeBase64(encodedText)
Var newPageSetup As New PrinterSetup
newPageSetup.Settings=decodedText

I used the TextOutputStream and TextInputStream examples from the docs to save and load.

@Marvin_Clavey
There was a recent discussion about this, maybe can help you

https://forum.xojo.com/t/the-setupstring-prior-to-macos-26-is-not-read-now/87966/20

Download the examples folder (Option-Click in the Examples entry of the New Dialog:

and seach for a Print folder / example.

Will works for anything (probably) you will ask yourself “How will I do that ?”.

Of course, you can read the documentation then ask here !

When you will read this…

I removed the error with this code:

Sub Pressed() Handles Pressed
  Var ps As New PrinterSetup
  Var settingsFile As FolderItem = SpecialFolder.ApplicationData.Child("MyApp").Child("printer.config")
  Var bs As BinaryStream
  
  // Show dialog to user
  If ps.ShowPageSetupDialog Then
    // Save the settings string
    bs = BinaryStream.Create(settingsFile, True)
    If bs <> Nil Then
      bs.Write(ps.SetupString)
      bs.Close
    End
  End
End Sub

That is your code with a subtile change.

I do not clicked in the button since I have nothing at that address…

PS: avoid to use MyApp (to be replaced by your application Bundle Identifier (click in macOS - or…) in the Navigation Pane (left)
image

Regards.

I get the same error at the same line of code … must be a linux thing :slight_smile:

ok my next question was:
More information. OS, Xojo Version, what example?

Maybe upload zip of project?

I do not understand: do you have modified the line to look line the one I shared ?

I had the error with that line too:

Var bs As BinaryStream = BinaryStream.Create(settingsFile, True)

READ CAREFULLY MY CODE and apply the changes.

One more time: the code I shared compiles fine.
(and to do that I had to get the code in a project)

Here’s a project with a BevelButton and the shared code:
Printing.xojo_binary_project.zip (5.2 KB)