Unable to Print on Linux Mint
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Unable to Print on Linux Mint
Hmmm... I don't see any printer being instantiated other than an MCPSPrinter, and that in lnxpsprinter.cpp.
Am I missing something?
Am I missing something?
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: Unable to Print on Linux Mint
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...
Re: Unable to Print on Linux Mint
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.
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.
Re: Unable to Print on Linux Mint
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
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.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: Unable to Print on Linux Mint
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.

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.
Re: Unable to Print on Linux Mint
Maybe, but I think Richard said he just prints to pdf, and that's working for all of us.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: Unable to Print on Linux Mint
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.. ~ I ran Davel's script as posted using a simple field as text. The following pictures are what I saw in order - 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
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.. ~ I ran Davel's script as posted using a simple field as text. The following pictures are what I saw in order - 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


Re: Unable to Print on Linux Mint
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.

Re: Unable to Print on Linux Mint
@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
(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.
Code: Select all
lp /tmp/tmpprintfile.ps
@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.
Re: Unable to Print on Linux Mint
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
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
Re: Unable to Print on Linux Mint
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.

Re: Unable to Print on Linux Mint
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.
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.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: Unable to Print on Linux Mint
@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.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: Unable to Print on Linux Mint
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.
