FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveLinux / FiveDroid (Android) Five Linux Printing
Posts: 464
Joined: Tue May 16, 2006 07:47 AM
Five Linux Printing
Posted: Wed Mar 05, 2008 11:16 AM

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)

Posts: 169
Joined: Mon Feb 25, 2008 02:42 AM
Five Linux Printing
Posted: Fri Mar 07, 2008 08:32 AM

Hi Doug

I did my linux compiler without Fivelinux.

screen text mode only, not GUI :lol:

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

Posts: 464
Joined: Tue May 16, 2006 07:47 AM
Five Linux Printing
Posted: Fri Mar 07, 2008 01:05 PM
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:


%! 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


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:

moveto( 50, 500 )


whereas in postscript you have:

50 500 moveto


Of course an xBase class can hide that so you can call:

oPostscriptDocument:moveto( 50, 500 )


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:

oPostscriptDocument:atSay( 500, 50, "Example" )


Interestingly you don't have to directly generate a moveto and a show, because you can define functions in postscript such as this:

/atsay   @ (...) x y
{ moveto show } def


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)
Posts: 169
Joined: Mon Feb 25, 2008 02:42 AM
Five Linux Printing
Posted: Fri Mar 07, 2008 05:31 PM

Hi Doug !

I have some GUI libs based on GTK+ and libgnomeprint for printing.
Please your email address, I will send you the example

regards
fafi

Continue the discussion