OpenPrinter not working on Xojo2018r4

Hello Everyone,

I just moved on from Xojo 2016r3 to Xojo 2018r4 on my project and without changing anything OpenPrinter method throws exception.

Common\runprint.cpp: 180
Failure Condition: returnGfx

My Code

If ivPrPrinterId>0 Then
  Dim s As String
  s = "KPRINTER_"+ivPrPrinterId.toString()
  If rgPrinterSetupGet(ps, s) Then
  End If
End If

ivGraphics = OpenPrinter(ps) // Pending to remove the "Dialog"

Public Method (byRef ps As PrinterSetup, configType As String = “GenericInvoicePrinterSetup”) returns Boolean

Dim s As String

If Not(GetConfigValue(configType, s)) Then
Return False
End If

If s = “” Then
Return False
End If
s = DefineEncoding(s, Encodings.ASCII)
'MsgBox(s.Encoding.internetName)
Dim mb As MemoryBlock = DecodeBase64(s)

Try
ps.SetupString = mb
Catch e As IOException
Return False
End Try

Return True

Above is the code where I save my PrinterSetup

Dim mb As MemoryBlock

mb = ps.SetupString

Dim s As String

s = DefineEncoding(EncodeBase64(mb), Encodings.ASCII)

Return PutConfigValue(configType, s)

Has anyone come up with this one?

Thank you in advance.

If this is about TargetWindows…

That‘s bye, bye GDI - Hello Direct2D

Are you trying to pass in a PrinterSetup/String you‘ve saved in 2016r3/GDI?
Then that‘s not going to work (as far as i remember from reading the forums). You‘ll have to get a new one for the Direct2D Xojo versions.

I recommend to skip anything between 2016r3 and 2019r1.1. Move to 2019r1.1 if you can.

I have saved again the PrinterSetup without the encoding and it worked.
The only thing that I have to mention is that when you use for example the XPS and it opens the window to save the file.
If you press Cancel then Xojo throws that something went wrong and the application closes.
If you save the file everything work ok.

Rick my plan is to use 2019r1.1 but because we have the MBS plugins for 2018 r4 I tried to move on first on 2018 r4 and when everything works ok then we will move on to 2019r1.1
Thank you for your advice :slight_smile: