Forum Moderators: coopster & phranque

Message Too Old, No Replies

perl and printer fonts

         

littleman

2:05 pm on Dec 6, 2002 (gmt 0)



So I could use perl to print by doing th following code:
open(PRINTER,'¦lpr') ¦¦ die "Cant open printer - $!\n";
print PRINTER $final;
close(PRINTER);

Does anyone know a way to have perl manipulate the font settings?

seindal

2:49 pm on Dec 6, 2002 (gmt 0)

10+ Year Member



With code as in the example, the choice of font is entirely up to the printer driver. Depending on your choice of print spooler you might have different ways of sending options to the driver through the lpr command line.

I assume your $final just contains flat text.

If you want to have finer control over page rendering you have to generate postscript or if your program has a gui, use gnome-print or similar tools.

Maybe the easy way out is to add to the pipeline, sending your text through enscript or some other text->postscript engine. They usually let you decide the font face, size etc.

There are many ways (as there should be), so it all depends on the specific needs and constraints of the task at hand.

René.

littleman

8:32 pm on Dec 6, 2002 (gmt 0)



Rene.
Good pointers, thanks.

andreasfriedrich

1:30 am on Dec 7, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I use perl to produce latex source. Makes for very beautiful documents and you have total control over the layout. Producing latex source is easier then writing a postscript program.

Andreas

seindal

2:05 am on Dec 7, 2002 (gmt 0)

10+ Year Member



There is also the possibility of generating HTML and convert it to postscript. There is a html2ps program, written in perl. I haven't tried it, but it appears to use a CSS like syntax for presentation specification, so it should be quite handy.

I just tried it on my Debian system, and it is not perfect, but for simple things it will probably be ok. It does lists, tables, fonts ... It also displays javascript!

René

andreasfriedrich

3:10 pm on Dec 7, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As you write html2ps is ok for simple thinks and I have used it for that. However, it is not suitable to set books or longer articles. And once you have setup the latex framework you will use it for simple things as well. :)

Andreas

seindal

6:13 pm on Dec 7, 2002 (gmt 0)

10+ Year Member



That is true. In the end it all depends on what littleman is actually doing and how important it is.

That's exactly the importance of having always many ways of doing things. Sometimes one solution is the best, at other times another.

René.

littleman

7:02 pm on Dec 7, 2002 (gmt 0)



Fortunately, I was able to find a GPL script to do exactly what I was looking to accomplish. :) Piping through postscript seems to be a daunting process from looking at the source code. Andreasfriedrich, I like the latex approach.

html2ps would be handy, but it wouldn't work in this case. Thanks both for the solid advice.