Printing failures in Linux

Hi all -

So, after all this time has anyone gotten printing to work under Linux?

Dim ps As New PrinterSetup
g = OpenPrinterDialog(ps, Self)

POOF!

No traceback, can’t trap it - even with a Try … Catch.

2022r2
MBS 22.1
4 different Linux distros
Works as expected on Windows and macOS

see also: Issue 58365

reported 2 years ago… a hard crash of built applications, but not yet fixed. :slightly_frowning_face:

nominated for bug bash, but didn’t get picked to fix (yet).

Have-you printed something (anything) with this computer/boot disk ?
Have-you a selected printer ?

My attempts to print under linux fail with:

  1. Linux Mint running in a VM
  2. Raspbian running on a Pi

Yes. In all cases trying to print causes the app to crash hard, even under remote debugging. No chance AT ALL to see what is happening. Try/Catch is no help.

Sorry Tim.

I was asking if you printed something (not with Xojo) from that computer. If yes, I do not know.

At print time, you have to check if the Print process is ready to do its job (there is a default printer, the “Print Manager” is ready to work, etc.)

I have verified all cases using the 2022r2 IDE on Mint, Debian, Fedora, and Arch - The ONLY way to get the Printer Dialog to popup and not silently hard crash the app is to disable Networking and make sure that any local printer is not being reported as a networked printer.

1 Like

My own printing needs are modest—just print a plaintext log file if the user wants, but on Linux what I did was to build into my projects a whitelist of distros where I’ve confirmed that Xojo printing works. Only on these is the Page Setup menu enabled.

There is an older thread on this print crash in the forum, particularly discussing Mint. Another gentleman shared some workaround code in which Xojo’s own printer dialog is bypassed, and instead shell commands are sent for LibreOffice to do the work under the hood. I got this to work (presuming LibreOffice is there), and my Print menu uses this as Plan B on the “black” distros.

Edit: talking here about networked printing, as Tim says.

And … one run this morning worked with networking ENABLED …

Built a new build … failed again. Ran in the debugger … failed again.

:angry:

Jerry, which versions of Linux have you confirmed printing works?

1 Like

Going by my own VM “farm”, I developed a whitelist. My apps run a shell to check the results of “cat /etc/os-release” against this.

My whitelist is Debian, Ubuntu, OpenSUSE Leap, CentOS and Arch. Um, I think I can trim the CentOS. :slight_smile:

For me, that leaves out Mint and Gentoo. For these, I successfully use this workaround that I got from another discussion here (note that the example deals with plain text , which is all I need.)

Dim f_print as new FolderItem
'Substitute your desired file name
f_print = SpecialFolder.temporary.Child("serverLog.txt")
If f_print <> nil then
  
  Dim myStream as TextOutputStream=TextOutputStream.Create(f_print)
'Substitute your desired string
  myStream.Write LogWindow.Text
  myStream.Close
  
end if

dim s as Shell
s = new shell
'This will have LibreOffice print for us under the hood.
s.execute ("libreoffice --headless -p  /tmp/serverLog.txt")

if s.ExitCode<>0 then
  
'Well, I guess the user doesn't have LibreOffice.  But at least we did this instead of hard crashing with Xojo print.

End if

end if

Printing requests from “bad” distros get redirected to this method instead of native Xojo printing.

Edit: As I recall, the original example handled RTF, but I had problems with that (it’s been awhile.) Like I said, plain text worked and was all I needed anyway.