Printing confusion and questions

I am looking at the printer sample and having two issues. First system spec in case they are needed.

-devtop :
OS: Linux Mint 19.3 Tricia x86_64
Host: GL73 8RC REV:1.0
Kernel: 5.4.0-42-generic
Uptime: 1 day, 19 hours, 8 mins
Packages: 2558
Shell: bash 4.4.20
Resolution: 1920x1080
DE: Cinnamon 4.4.8
WM: Mutter (Muffin)
WM Theme: Mint-Y-Dark (Mint-Y)
Theme: Mint-Y [GTK2/3]
Icons: Mint-Y [GTK2/3]
Terminal: gnome-terminal
CPU: Intel i7-8750H (12) @ 4.100GHz
GPU: Intel Integrated Graphics
GPU: NVIDIA GeForce GTX 1050 Mobile
Memory: 3092MiB / 31958MiB
Printer: Epson WF7610

Issue 1 - When I try to print to printer the app dies without warning while attempting to open the printer dialog. I see the printer window open but then poof, it goes away and the app drops back into the IDE without error message.

Issue 2 - My cranial capacitor is not getting around how to call the report then print it. I have a simple report with a couple of fields that I want to populate from a calling Window. I know how to pass parameters but the print thing… how do I preview the report? And then there is issue 1.

A known issue
http://feedback.xojo.com/case/58365
http://feedback.xojo.com/case/51975
http://feedback.xojo.com/case/20670
http://feedback.xojo.com/case/6919

Saving a file to disk then using a shell command to print might be an option

Thanks Norman, I’ll poke at that! Let you know in a bit if it works… but… how do I write the report formatted to a file? It has one rather large image associated with it (company logo). This is a realm I have yet to delve into.

Hmm, so I am trying to get a basic shell command to work and it’s not… I have everything setup correctly…

// Variable declarations...

Var cmdPrn As String
Var shTerm As New Shell

// Function(s)…
'cmdPrn = “lpoptions -d EPSON_WF_7610_Series”
'shTerm.Execute( cmdPrn )

cmdPrn = “cd /home/ian/Development” '/Joyful\ Heart\ Garden\ Center\Gift\ Cert\ DB"
shTerm.Execute( cmdPrn )

If shTerm.ErrorCode = 0 Then
MessageBox( shTerm.Result.ToText )
Else
MessageBox( "Error " + Str( shTerm.ErrorCode ) )
End If

cmdPrn = “pwd”
shTerm.Execute( cmdPrn )
MessageBox( shTerm.Result.ToText )

Note that a shell is NOT a “terminal window”
So one command using execute after the other behaves INDEPENDENTLY of the others
Think of it like each execute opens a terminal, runs the command, closes the terminal

The CD takes place and does its thing and the next execute behaves as if the CD was NEVER done

In order to run several successive commands you either need to construct it as one long command OR use a different shell mode which doesn’t behave like this(interactive or async)
see http://documentation.xojo.com/api/os/shell.html#shell-executeMode

Change your shell to async and use the Write/WriteLine functions:

Var cmdPrn As String
Var shTerm As New Shell

shTerm.ExecuteMode = Shell.ExecuteModes.Asynchronous
                     // ^^^ I HATE the new API for this...

// Function(s)…
shTerm.Execute("/bin/bash -i")
shTerm.WriteLine("PS1=input:\ ") // Makes it easier to catch end of command since we can't 
                                 //  depend on IsRunning using a shell in this manner
cmdPrn = “lpoptions -d EPSON_WF_7610_Series”
shTerm.WriteLine( cmdPrn )
Do
    shTerm.Poll
    App.DoEvents(5)
Loop Until InStrB(shTerm.Result, "input: ") <> 0
Call shTerm.ReadAll // Throw away the current text

// I believe that you probably need an lpr command around here ...
cmdPrn = “cd /Joyful\ Heart\ Garden\ Center\Gift\ Cert\ DB"
shTerm.WriteLine( cmdPrn )
Do
    shTerm.Poll
    App.DoEvents(5)
Loop Until InStrB(shTerm.Result, "input: ") <> 0 Or Not shTerm.IsRunning
Call shTerm.Readall
If shTerm.ErrorCode = 0 Then
    MessageBox( shTerm.Result.ToText )
Else
    MessageBox( "Error " + Str( shTerm.ErrorCode ) )
End If

cmdPrn = “pwd”
shTerm.WriteLine( cmdPrn )
shTerm.WriteLine( "exit" )
MessageBox( shTerm.ReadAll.ToText )

Is there a way to use a terminal window in the background? Right now my solution is to write a bash script to do everything I want then invoke it from shell… what’s your opinion? Funny thing is I still haven’t broached writing a formatted document! Which brings up… can I write a file out as a pdf from xojo? Or is there some other magic required?

This is what I need to create:

The above image is an OpenOffice spreadsheet with two sheets, the final which you see and the “source” worksheet. Right now I create the gift certificate information with my application and write the required data to disk, open the text file created and copy paste the output into the "source’ worksheet then print the Gift Certificate worksheet.

Originally I wanted to write the data directly into an OpenOffice spreadsheet and print from there, but I haven’t heard any replies as to if that is possible. This is all new territory for me as most of my programs have been pretty simple and for my use. But this is for some pretty techtarded folks and I am building it as reliable and simple to use as possible. Basically making it so a cavechimp could run it.

ok to run the bash script you dont need a “terminal” since the bash script would be one command run by a shell

Xojo does not directly have any built in means to write a PDF
There are other ways to do this ranging from free to expensive and they come with varying ranges of capabilities (which you might expect)

I know some have used

  • wkhtmltoPDF which is a small app that lets you write HTML that it converts to a PDF
  • Einhugurs PDF plugin (the Excel one might be useful)
  • Monkeybreads PDF plugin

There are others as well by google foo just isnt finding them right now

Normally I’d say "oh just draw that but since open printer etc fails spectacularly on Linux thats not really an option

[quote=“John_McDonald, post:7, topic:55253, full:true”]Originally I wanted to write the data directly into an OpenOffice spreadsheet and print from there, but I haven’t heard any replies as to if that is possible.
[/quote]
it might be but I’ve never experimented with it so really dont know for sure