I thought I would ask what approach(es) people are taking with printing under FiveLinux.
A few years ago, before I discovered the wonderful world of xHarbour / FiveLinux I played around with FlagShip (also xBase dialect on Linux). I wrote a series of functions then to create postscript files direct from my application. That involved quite a few public variables. In an xHarbour / FiveLinux environment you would write a class and use class properties and methods.
I've started to do that, but before I got too far thought I should find out what others are doing.
Also if others are interested in a postscript class (would also work in a Windows environment) let me know.
I would be interested to hear from you.
Regards
Doug
(xProgrammer)
Five Linux Printing
Hi Doug
I did my linux compiler without Fivelinux.
screen text mode only, not GUI
function main()
local cFilePrint := "report.prn"
set console off
set printer on
set printer to (cFilePrint)
?"Hello xProgrammer"
?"I'm Fafi"
?"Thank's for help"
set console on
set printer off
__run("lpr "+cFilePrint)
return nil
regards
Fafi
I did my linux compiler without Fivelinux.
screen text mode only, not GUI
function main()
local cFilePrint := "report.prn"
set console off
set printer on
set printer to (cFilePrint)
?"Hello xProgrammer"
?"I'm Fafi"
?"Thank's for help"
set console on
set printer off
__run("lpr "+cFilePrint)
return nil
regards
Fafi
- xProgrammer
- Posts: 464
- Joined: Tue May 16, 2006 7:47 am
- Location: Australia
Hi Fafi
That's good but if you want more control over your printer (like graphics, controlling fonts) you'll need a more sophisticated approach.
If you have a postscript printer you might want something like this in cFilePrint:
I need to output some pretty fancy forms amongst other things. I am hiding some of the ways postscript works that run counter to how we expect them in xBase such as:
postscript measures up from the bottom of the page
in postscript you put data on the stack which is then pulled off by operators as required. In xBase we would expect something like:
whereas in postscript you have:
Of course an xBase class can hide that so you can call:
which would add the corresponding moveto command to the postscript document being built.
In fact rather than use moveto and show you can define an "atsay" method so that you can code:
Interestingly you don't have to directly generate a moveto and a show, because you can define functions in postscript such as this:
Also rather than have to work vertically from the bottom by setting a page height and top margin in the class instance you can work from the top down (in xBase), the object doing the coordinate conversions for you.
That's where I'm currently headed.
Regards
Doug
(xProgrammer)
That's good but if you want more control over your printer (like graphics, controlling fonts) you'll need a more sophisticated approach.
If you have a postscript printer you might want something like this in cFilePrint:
Code: Select all
%! sample postscript file
Helvetica-Bold findfont
12 scalefont
setfont
50 500 moveto
(This is an example) show
% draw a box
newpath
50 400 moveto
50 300 lineto
150 300 lineto
150 400 lineto
closepath
stroke
showpage
postscript measures up from the bottom of the page
in postscript you put data on the stack which is then pulled off by operators as required. In xBase we would expect something like:
Code: Select all
moveto( 50, 500 )
Code: Select all
50 500 moveto
Code: Select all
oPostscriptDocument:moveto( 50, 500 )
In fact rather than use moveto and show you can define an "atsay" method so that you can code:
Code: Select all
oPostscriptDocument:atSay( 500, 50, "Example" )
Code: Select all
/atsay @ (...) x y
{ moveto show } def
That's where I'm currently headed.
Regards
Doug
(xProgrammer)