Unable to Print on Linux Mint

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Unable to Print on Linux Mint

Post by mwieder » Sun Mar 15, 2020 8:36 pm

Hmmm... I don't see any printer being instantiated other than an MCPSPrinter, and that in lnxpsprinter.cpp.
Am I missing something?

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1232
Joined: Thu Apr 11, 2013 11:27 am

Re: Unable to Print on Linux Mint

Post by LCMark » Sun Mar 15, 2020 8:40 pm

Yes - but that generates a postscript file which is then passed to lp - printing systems (to my knowledge) on Linux rely on Ghostscript which, being a full ps interpreter, supports postscript and pdf. Ghostscript is where all the rasterisation and eventual sending to the actual printer occurs... Unless Mint is doing something radically different under the hood...

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1232
Joined: Thu Apr 11, 2013 11:27 am

Re: Unable to Print on Linux Mint

Post by LCMark » Sun Mar 15, 2020 8:50 pm

Now actually at my computer to check...

In fact, it actually uses the PDF printer (inside MCPSPrinter) - we updated that in October 2015 so that change would have appeared either in LC 7.1 or LC 8.0. So we generate a PDF to a temp file and then tell lp to do its thing (MCPrinterResult MCPSPrinter::DoEndPrint(MCPrinterDevice* p_device)).

So my guess would be something is awry with the lp command being executed - given that it sounds like in @DaveI's case saving to a pdf file explicitly is working.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Unable to Print on Linux Mint

Post by mwieder » Sun Mar 15, 2020 9:02 pm

Well, my experience is the same as Dave's... I've just assumed it was one of the LC Things That Don't Work on Linux. Didn't realize it was actually supposed to work.

and I'm a bit thrown off by the following
MCPrinterResult MCPSPrinter::DoEndPrint(MCPrinterDevice* p_device)
{
// If we have no PDF printer, then we can't do anything.
Last edited by mwieder on Sun Mar 15, 2020 9:07 pm, edited 1 time in total.

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1232
Joined: Thu Apr 11, 2013 11:27 am

Re: Unable to Print on Linux Mint

Post by LCMark » Sun Mar 15, 2020 9:07 pm

Heh - well, in this case since @FourthWorld mentions it works on Ubuntu, it sounds like 'one of the LC Things That Don't Work on Linux *Mint*' ;)

That being said there's a very small set of things that could be the problem - lp isn't working, lp doesn't like one of the computed arguments being passed to it, or /tmp/tmpprintfile.ps (which appears to be the fixed file which is used - erg!) isn't actually written or isn't readable by lp.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Unable to Print on Linux Mint

Post by mwieder » Sun Mar 15, 2020 9:08 pm

Maybe, but I think Richard said he just prints to pdf, and that's working for all of us.

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Unable to Print on Linux Mint

Post by bogs » Sun Mar 15, 2020 9:23 pm

Wow, lots went on while I was testing heh. Here was what I got -

Closest setup I had to what Davel has was LM 18 / Cinnamon + Lc 9.5.x

Since I was running off a live ISO (skipped the install), I ran Lc from a shared folder as root. It didn't make much of a difference, I don't think**.

~First, I made sure the Live cd would print to the printer, it did..
aPic_LcPrint1.png
Printer as shown by Live CD Printer Dialog..
~ I ran Davel's script as posted using a simple field as text. The following pictures are what I saw in order -
aPic_LcPrint2.png
It answered the printer...
aPic_LcPrint3.png
This is all it said for 'printer output'...
I added LcMark's suggestion of 'put result', that came back blank.

When I modified the script by commenting out Davel's code, and instead saved the field to a text file, then shelled lp "filename", it printed from the printer, although of course I didn't set any margins etc etc etc etc. .

I am not sure what conclusions you can draw from this testing, but it would seem that lp *is* working correctly, and that it is instead something in the way Lc is calling it.

**I am sure that statement will come back to bite me :P
Image

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Unable to Print on Linux Mint

Post by bogs » Sun Mar 15, 2020 9:25 pm

As a cont. of the above post, there was an error result in Lc after completing the printing, but that might be due to the way I used the shell heh.
aPic_LcPrint5.png
I thunk I dun somtin wrong 'ere...
Image

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1232
Joined: Thu Apr 11, 2013 11:27 am

Re: Unable to Print on Linux Mint

Post by LCMark » Sun Mar 15, 2020 9:28 pm

@bogs: That is very useful testing... So since you have just tried a printing loop on Linux there - is there a /tmp/tmpprintfile.ps on your system? If so, what happens if you do

Code: Select all

lp /tmp/tmpprintfile.ps
(from Terminal).

@mwieder: I missed you 'bit thrown off by' presumably "// If we have no PDF printer, then we can't do anything." The PDF Printer component is optional in standalones, so if you don't include it in them, then it isn't there to generate the PDF. That doesn't sound like it is the problem though here as it sounds like this is reproducable in the IDE and explicit PDF printing to a file (as well as printing to a pdf file from the print dialog) works.

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Unable to Print on Linux Mint

Post by bogs » Sun Mar 15, 2020 9:35 pm

I don't see that here, Lc Mark -
aPic_LcPrint6.png
Whats in a name ??
Image

DaveI
Posts: 8
Joined: Sat Mar 14, 2020 9:55 pm

Re: Unable to Print on Linux Mint

Post by DaveI » Sun Mar 15, 2020 11:20 pm

Thanks for all your efforts gentlemen. I'll have a go at printing to pdf and then using lp to print that file. I've never run a shell command from within LC but you've given me enough clues to work that out.

My app uses two print routines, one to print receipts to a laser and the other labels to a Zebra printer. So I could, at a pinch, hard code those into the program rather than call up the printer selection window. Shame because that is such an elegant way to do it.

I guess not that many people use LiveCode on Linux but it was one of the reasons I chose it when I wrote the app. If I tell you that when I was looking, Windows Vista had just been released and was such a dogs dinner, you'll understand why I was looking for a solution that was quickly transferable to another OS.

I'll let you know how I get on. All the best - Dave

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Unable to Print on Linux Mint

Post by bogs » Sun Mar 15, 2020 11:34 pm

DaveI wrote:
Sun Mar 15, 2020 11:20 pm
I'll have a go at printing to pdf and then using lp to print that file. I've never run a shell command from within LC but you've given me enough clues to work that out.
Heya Dave,

Depending on what your printing, you really can skip the pdf part of the process, myself, I'd probably export a screen shot if the card doesn't have scrolling fields.

The shell command is far simpler than what I did, you can read up on it at Max's excellent wiki, or at the dictionary.
Image

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Unable to Print on Linux Mint

Post by mwieder » Mon Mar 16, 2020 12:51 am

Update:

If I print to a pdf file it the file is generated with no problems and looks fine.
If I print to a physical printer there is no /tmp/tmpprintfile.ps file generated.
If I run lp from a command prompt with all (or a subset of) the arguments in lnxpsprinter.cpp I can print the generated pdf file.

(probable bug) if I specify a path for the pdf file (I sent it to my desktop) that is sticky until I restart LiveCode. Switching to a physical printer changes the printerName from "print to file" to my printer name, but the printerOutput never changes to "device", it just stays at the Desktop file path.

If I copy the pdf file I generated earlier into the /tmp directory and rename it to tmpprintfile.ps then I can print to my printer. But only the file I previously generated - it doesn't get overwritten by newer information.

I've been searching for the code that generates the temp file and I haven't yet found it. That may be significant, but more likely it's my unfamiliarity with this section of code.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Unable to Print on Linux Mint

Post by mwieder » Mon Mar 16, 2020 12:54 am

@LCMark - thanks for the explanation about the 'no pdf printer' thing. That makes sense and no, I don't think it has any bearing on what we're seeing.

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Unable to Print on Linux Mint

Post by bogs » Mon Mar 16, 2020 9:10 am

Since this wasn't a Mint specific issue, I continued testing through the previous versions of Lc on my own machine. The last version the print worked (as far as creating the temp file and printing to the printer) was in 7.1.4, in 8.0.1 to present, no temp file shows up.
Image

Post Reply