Five Linux Printing

Five Linux Printing

Postby xProgrammer » 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)
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Postby fafi » Fri Mar 07, 2008 8: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
User avatar
fafi
 
Posts: 169
Joined: Mon Feb 25, 2008 2:42 am

Postby xProgrammer » Fri Mar 07, 2008 1: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:


Code: Select all  Expand view
%! 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:

Code: Select all  Expand view
moveto( 50, 500 )


whereas in postscript you have:

Code: Select all  Expand view
50 500 moveto


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

Code: Select all  Expand view
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:

Code: Select all  Expand view
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:

Code: Select all  Expand view
/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)
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Postby fafi » Fri Mar 07, 2008 5: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
User avatar
fafi
 
Posts: 169
Joined: Mon Feb 25, 2008 2:42 am


Return to FiveLinux / FiveDroid (Android)

Who is online

Users browsing this forum: No registered users and 3 guests