Unable to Print on Linux Mint
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Unable to Print on Linux Mint
Hello gentlemen,
Last night I cracked it with a good work round. See below.
on Mouseup
local tPrinter, tPath, tShell
-- first create the pdf in /tmp
put "/tmp/Livecode/tempfile" into tPath
open printing to pdf tPath
print this card
close printing
-- Now use os Print selector window to choose a printer and print the pdf
answer printer
if the result is not "Cancel" then
put printerName into tPrinter
put "lp -s -d "&&tPrinter&&" "&&tPath into tShell
launch tShell
put "rm "&&tPath into tShell
launch tShell -- Clean up and delete the temporary pdf file
end if
end Mouseup
This works well and to the user, appears just like the original. I use the standard printer selector window to choose a printer, which I then use within the unix lp command to actually do the printing. I use launch to execute the shell command rather than shell because it doesn't show the message window.
I think I might develop this into a generic printer function so I'd call it with the path and the id of the card to print.
Thank you so much for all your efforts and the information you gave me. It's been an interesting little challenge and I feel quite satisfied with the result. FYO I'm a 75 year old ex contract programmer, mainly C and Informix but I haven't done much coding for years so it stretched the brain cells a bit. The app is for the accounts and order processing for my retirement company, The Violin Company - you'll find it on the web. Nice thing about violins they don't get hacked etc.
Best wishes to you all and thanks again. - Dave Ingledew
Last night I cracked it with a good work round. See below.
on Mouseup
local tPrinter, tPath, tShell
-- first create the pdf in /tmp
put "/tmp/Livecode/tempfile" into tPath
open printing to pdf tPath
print this card
close printing
-- Now use os Print selector window to choose a printer and print the pdf
answer printer
if the result is not "Cancel" then
put printerName into tPrinter
put "lp -s -d "&&tPrinter&&" "&&tPath into tShell
launch tShell
put "rm "&&tPath into tShell
launch tShell -- Clean up and delete the temporary pdf file
end if
end Mouseup
This works well and to the user, appears just like the original. I use the standard printer selector window to choose a printer, which I then use within the unix lp command to actually do the printing. I use launch to execute the shell command rather than shell because it doesn't show the message window.
I think I might develop this into a generic printer function so I'd call it with the path and the id of the card to print.
Thank you so much for all your efforts and the information you gave me. It's been an interesting little challenge and I feel quite satisfied with the result. FYO I'm a 75 year old ex contract programmer, mainly C and Informix but I haven't done much coding for years so it stretched the brain cells a bit. The app is for the accounts and order processing for my retirement company, The Violin Company - you'll find it on the web. Nice thing about violins they don't get hacked etc.
Best wishes to you all and thanks again. - Dave Ingledew
Re: Unable to Print on Linux Mint
Gee Dave, you could at least have linked the name to the address
Is this it? https://www.violincompany.co.uk
Glad you figured out the coding problem young man

Is this it? https://www.violincompany.co.uk
Glad you figured out the coding problem young man


Re: Unable to Print on Linux Mint
Hi Bogs,
Yes it is the correct address
I can't put links in messages on here - maybe because I'm a newby.
Now I've got another problem - but I haven't looked on the forum yet to see if there's an answer. The pdf rendering is a bit odd and at the moment it's only in one field, which is a customer name. If the name is Joe Bloggs all I get is J, if it's Bill Jones I get Bill J when I check the property of the field and show the contents it's exactly as I expect but by the time it gets to the pdf it's missing bits. I've also noticed it won't register Williams. If I exit from Livecode, go back in then it prints fine the first time and maybe the second. I'm wondering if there's a clear fields or something I need to do between prints. I've tried putting the name into another field on the card and it's just the same.
I'll trawl through the forum comments and see whether someone else has had problems -- It was going so well too
Yes it is the correct address

Now I've got another problem - but I haven't looked on the forum yet to see if there's an answer. The pdf rendering is a bit odd and at the moment it's only in one field, which is a customer name. If the name is Joe Bloggs all I get is J, if it's Bill Jones I get Bill J when I check the property of the field and show the contents it's exactly as I expect but by the time it gets to the pdf it's missing bits. I've also noticed it won't register Williams. If I exit from Livecode, go back in then it prints fine the first time and maybe the second. I'm wondering if there's a clear fields or something I need to do between prints. I've tried putting the name into another field on the card and it's just the same.
I'll trawl through the forum comments and see whether someone else has had problems -- It was going so well too

Re: Unable to Print on Linux Mint
Your linking inability will end in 2 more posts (as of your last post, 10 is the magic number heh).
Curious new issue, is the whole name visible in the field, or does it extend beyond the rect of the field?
Curious new issue, is the whole name visible in the field, or does it extend beyond the rect of the field?

Re: Unable to Print on Linux Mint
Nice update to the BR Mark, but having read it, I wonder how Panos managed to get it to print? I couldn't using Ubuntu 16.04. What a mystery 


Re: Unable to Print on Linux Mint
My wild-ass guess (without having any actual data to work with) is that there was already a /tmp/tmpprintfile.ps file in existence, since the print command doesn't delete it when it's done. If that's the case then, as I've discovered) the print-to-printer invocation of lp does print that file. But who know? I'm guessing that Panos won't remember from two years ago either.
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
LOL! I wouldn't be surprised if your dead on the mark, erm... Mark 


Re: Unable to Print on Linux Mint
To be fair we could not reproduce that bug at the time - and there was no further input from anywhere else, so it would have been assumed to be an isolated incident. Of course, this is obviously not the case 
I was the one who actually wrote the relevant patch which replaced the previous PS generation with the PDF printer - so I can be sure it definitely did work on the system I was using to write it at the time - and the code in the engine at least looks correct (okay, so its ugly and it shouldn't be using a fixed output path), so it is strange. (The only thing I can think of is that something environmental changed between 2015 and 2018 which renders the approach taken inappropriate!).
However, the important thing is that we now know that for some reason the pdf file isn't actually being generated in this case. So that's a step forward

I was the one who actually wrote the relevant patch which replaced the previous PS generation with the PDF printer - so I can be sure it definitely did work on the system I was using to write it at the time - and the code in the engine at least looks correct (okay, so its ugly and it shouldn't be using a fixed output path), so it is strange. (The only thing I can think of is that something environmental changed between 2015 and 2018 which renders the approach taken inappropriate!).
However, the important thing is that we now know that for some reason the pdf file isn't actually being generated in this case. So that's a step forward

Re: Unable to Print on Linux Mint
I hope my remarks weren't taken as a slam on anyone, I just was genuinely curious. If anyone felt slighted, I apologize as that wasn't the intent 


Re: Unable to Print on Linux Mint
@bogs: Not at all - I was just adding what I can remember to the mystery... In that I know it worked once (I can't recall what Linux distro/version I might have been using!) and thus it is plausible it still worked for Panos when he tried to reproduce... Although it could well be a case of @mwieder suggested - a non clean test environment. Of course, the question still remains why is the engine not able to write a file to /tmp/tmpprintfile.ps when it is clearly possible for such a thing to be there, and be piped to lp!
Re: Unable to Print on Linux Mint
Just making sure, I know my ... ability to filter correctly is pretty terrible and is sometimes misunderstood <that REALLY is putting the best face on it, eh?
>.
As far as when it went awry, I know from the testing during this thread that it worked <more or less> in 7.1.4, but not in 8.0.1, which was what prompted me to wonder why it would have worked for Panos in 8.1.9
I have no doubt Mark hit it on the head, it isn't something almost anyone would think of and, as you say, it was working, there wasn't a mass complaint setup when it stopped, it appeared the easiest explanation was a one time occurrence.
As Richard Dawson said in "Running Man", all part of life's rich pattern...<sic>...Get used to it! Hee hee

As far as when it went awry, I know from the testing during this thread that it worked <more or less> in 7.1.4, but not in 8.0.1, which was what prompted me to wonder why it would have worked for Panos in 8.1.9

I have no doubt Mark hit it on the head, it isn't something almost anyone would think of and, as you say, it was working, there wasn't a mass complaint setup when it stopped, it appeared the easiest explanation was a one time occurrence.
As Richard Dawson said in "Running Man", all part of life's rich pattern...<sic>...Get used to it! Hee hee

