Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Printing to printer - Linux - LPRINT alternative?
#1
Hi everyone.

I see that LPRINT is not operational in the Linux version.

Is there an alternative way to print? Happy to print straight to a pdf, or image.

Many thanks.   Smile
Reply
#2
Welcome to the forums.

Sadly QB64 is too Windows-focused. We cannot wait until we die until this functionality is included.

What do you want to commit to paper? Could you use GIMP or Libre Office for it? Yes I know, it sounds lame.

Damn not even _CLIPBOARDIMAGE? I wanted to propose that so at least the image to copy to clipboard is pasted into GIMP and printed.

It might be possible to pipe image output to some other program that does the printing.

This might have good food:

https://askubuntu.com/questions/1123266/...a-terminal

In QB64, you use SHELL command to execute a command meant for the terminal. It's like "system()" for C run-time libraries, GAWK and other programming utilities, it requires a valid string as if it were typed directly at the terminal. With SHELL you use HIDE option if you don't want to see a "bash" box on the screen while the command executes. Such as:

Code: (Select All)
SHELL HIDE "mycommand myparameters -optoan blah blah"
Reply
#3
Thanks very much. Let me work with that.   Smile

I'll report back on how it works out.

PS: I'm updating code I originally wrote ~35 years ago for heat-exchanger design. Having a lot of fun. The early days of the 386 and maths co-pro.   Wink
Reply
#4
(05-26-2023, 12:03 PM)desA Wrote: Thanks very much. Let me work with that.   Smile

I'll report back on how it works out.

PS: I'm updating code I originally wrote ~35 years ago for heat-exchanger design. Having a lot of fun. The early days of the 386 and maths co-pro.   Wink

Welcome to the forum. Smile
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply
#5
OK so _PrintImage doesn't work in Linux, how about under Wine?
b = b + ...
Reply
#6
(05-26-2023, 04:08 PM)bplus Wrote: OK so _PrintImage doesn't work in Linux, how about under Wine?

What if desA doesn't have Windows and only Linux?

You need Windows to come up with a Windows EXE file, to then use it in Linux with Wine. It might be possible to create an EXE file with "gcc/g++" chain through MinGW but I don't know anything about that.

Some Linux users don't like "systemd" but sadly the best Windows support through Wine comes from distros like Arch, Debian and Fedora that carry that startup thingie. Install QB64 for Windows on Linux only to compile Windows EXE programs? Might be faster actually being in Windows and doing it. But it's going to be a major memory hog and in a large project, it could be unacceptable.

All the Linux-only options have to be exhausted before going with Wine because this wants over 2GB of dependencies, and data generated by "winecfg". Also headaches about it, for example running "winecfg" on the "soon to be stable" Debian "Bookworm" v12 which could hang for several minutes and give up timing out on "wineboot" which is irritating.
Reply
#7
Can't you download 32-bit windows version of QB64 and run them on WINE to make EXEs for WINE??
Reply
#8
I use Ubuntu on all my computers. Typically the server version on my servers, and desktop version on my notebooks.

Ubuntu is based on the Debian distro to the best of my knowledge.

A line by line dump to a text file would also be fine with me, as my LPRINT routines wrote to the printer on a line by line basis - not page at a time.

Does QB64 have a write to text file option?

Ahah - brainflash - I'll try the standard file output statements to write to text file line by line - with append - and see where that goes. A bit of jiggery-pockery...  Smile
Reply
#9
(05-27-2023, 02:12 AM)desA Wrote: Does QB64 have a write to text file option?

You could write text into a text file and use the file as candidate for "lp" terminal command or something else.

If you are writing a program that has to create its output as it goes, and it's harder to create one file out of it, then you use SHELL like I told you. First you put into a temporary file the stuff you expect printed. A sequential file for text, or a binary file for image. Then you use SHELL to call "lp" or other program that does the printing, using the temporary file as the input to that program called with SHELL.

You want a code block like:
Code: (Select All)
ff = freefile
open "/tmp/myfileforprint" for output as ff
'call function that create complex thing
f$ = mycomplexfunction
print #ff, f$
close ff
SHELL _HIDE "lp /tmp/myfileforprint"

I'm sorry I didn't look up the whole syntax of "lp" command but you'll get the general idea.

This code could be put into a subprogram and repeatedly called when you need to output something to the printer.

You could look at this but it might not be very helpful:

https://linux.org/threads/printing-image...nux.45232/
Reply
#10
You might need to create a picture out of a QB64 program to be printed out later, but the main problem is that it might need to be exported to PDF to make life easier. Because QB64 has no support for saving to BMP, PNG, JPEG, PDF or any other image format popularly used.

But you could import the following routine found on the first post of this thread:

https://qb64phoenix.com/forum/showthread.php?tid=1253

Do not further confuse yourself with other posts on that thread; the other solution might work also but it has much more code that works only on Windows. This is focused only on BMP, which sucks I know and you might prefer instead to export to PNG or something else. Also this SaveImage() routine is slow but does the job.
Reply




Users browsing this thread: 2 Guest(s)