enscript color


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting enscript color
# 1  
Old 08-15-2011
enscript color

Hi,
I am converting a text file to ps using enscript.
Does anyone know how to print in color?

Here is what I tried:

enscript -ptemp.ps -G -F Souvenir-DemiItalic20 -f Souvenir-DemiItalic20 -E --color file.txt

The color doesn't work
Thanks
# 2  
Old 08-16-2011
You can't colorize arbitrary text file. You need text of some predefined language (/usr/share/enscript/hl/*) or insert color tags in your file or define your own output language.
# 3  
Old 08-16-2011
Hi Yazu, thanks for the info
I tried this
enscript -ptemp.ps -G -F Souvenir-DemiItalic20 -f Souvenir-DemiItalic20 -E --color --language=html --output=file.txt file.txt

now it gives me the error message:
couldn't open AFM file for font "Souvenir-DemiItalic", using default
output left in file.txt

what am I doing wrong?
# 4  
Old 08-16-2011
1. Well, you convert your "file.txt" to html (--language=html). It's not me - the enscript manual uses the word "language" with different meanings. Smilie
2. Enscript knows nothing about Souvenir-DemiItalic font. You should convert (make AFM file for this font) by yourself. I don't know how, but I know it's possible. Smilie
# 5  
Old 08-18-2011
Hi was able to put some color in the file using a2ps
You can download a2ps from macports.

a2ps -R --column=1 --no-header --font-size=20 --pretty-print=js --highlight-level=heavy --pro=color --left-title=ITITLE1 --right-title=ITITLE2 -o temp.ps file.txt

_________________________________________________________________

Now this produces a file with only some of the words colored.

In order to make all the words colored I edited the js stylesheet.
Actually I created my own stylesheet and called it js2
You have to use awk ans sed commands to put the words from your file into the js2 file.

Here are the steps one by one.
1. First create a dummy file (js2.ssh) in the following directory opt/local/share/a2ps/sheets/ using command.

sudo vi /opt/local/share/a2ps/sheets/js2.ssh

2. Next link the file to your real js2.ssh file in your working directory
ln -s /opt/local/share/a2ps/sheets/js2.ssh ./js2.ssh

3. Next write a script to create js2.ssh file in your working directory here is a copy of my own called makejs2

##########################################
echo '# Style sheet for JavaScript'
echo '# Copyright (C) 2011 walforum'
echo ''
echo '#'
echo '# This file is part of a2ps.'
echo '#'
echo '#'
echo ''
echo 'style JavaScript is'
echo 'written by "Forumbaba <walforum@unix.com>"'
echo 'version is 1.1'
echo 'requires a2ps version 4.12g'
echo ''
echo 'first alphabet is'
echo ' "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_"'
echo 'second alphabet is'
echo ' "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789"'
echo 'case sensitive'
echo ''
echo 'documentation is'
echo ' "Keywords are generated from a text file"'
echo 'end documentation'
echo ''
echo 'keywords in Keyword are'
sed "s/[^a-z|^A-Z]/ /g;" $1 | sed "s/in/ /g;" | sed "s/is/ /g;"| sed "s/are/ /g;" | sed "s/ARE/ /g;" | sed "s/by/ /g;" | sed "s/end/ /g;" | sed "s/written/ /g;" | sed "s/first/ /g;"| sed '/^ *$/d' | sort -u | awk '{for(i=1;i<NF;i++)if(i%1==0){$i=$i","} }1' |awk '{ print " " $0 "," }'
echo ' love'
echo 'end keywords'
echo ''
echo 'keywords in Keyword_strong are'
sed "s/[^a-z|^A-Z]/ /g;" $1 | sed "s/in/ /g;" | sed "s/is/ /g;"| sed "s/are/ /g;" | sed "s/ARE/ /g;" | sed "s/by/ /g;" | sed "s/end/ /g;" | sed "s/written/ /g;" | sed "s/first/ /g;"| sed '/^ *$/d' | sort -u | awk '{for(i=1;i<NF;i++)if(i%1==0){$i=$i","} }1' |awk '{ print " " $0 "," }'
echo ' Jesus, God, Heaven, Lord, Father, Blessed, sin '
#echo ' All, sin, break, "case", catch, class, continue, default, delete, do, else, enum, '
#echo ' export, extends, final, finally, for, goto, if, implements, import, '
#echo ' "in", instanceof, interface, native, new, package, private, protected, '
#echo ' public, return, static, super, switch, synchronized, throw, throws, '
#echo ' transient, try, typeof, var, volatile, while, with '
echo 'end keywords'
echo ''
echo 'operators are'
echo ' (/(function)([[:blank:]]+)([^ \t(]+)/'
echo ' \1 Keyword_strong, \2 Plain, \3 Label)'
echo 'end operators'
echo ''
echo 'optional operators are'
echo ' # Actual'
echo ' && \wedge,'
echo ' || \vee,'
echo ' <= \leq,'
echo ' >= \geq,'
echo ' ! \not,'
echo ' # Protected from the above'
echo ' <<<=,'
echo ' <<=,'
echo ' >>=,'
echo ' >>>=,'
echo ' !=,'
echo ' !=='
echo 'end operators'
echo ''
echo 'sequences are'
echo ' # Regular expressions'
echo ' (/(=)/ # \1 = assignment'
echo ' /([[:blank:]]+)/ # \2 = spaces'
echo ' /(\/)/ # \3 = "/"'
echo ' /([^*\/])/ # \4 = first character of regexp'
echo ' \1 Plain, \2 Plain, \3 Plain, \4 String) String "/" Plain'
echo ' exceptions are'
echo ' "\\\\", "\\/"'
echo ' end exceptions,'
echo ' "/*" Comment Comment "*/" Comment,'
echo ' "//" Comment,'
echo ' C-string,'
echo ' "'" Plain String "'" Plain'
echo ' exceptions are'
echo "\\\\", "\\'"
echo ' end exceptions'
echo 'end sequences'
echo 'end style'
############################################


This script is run by ./makejs2 file.txt > js2.ssh

3. Next run the a2ps command again:
a2ps -R --column=1 --no-header --font-size=20 --pretty-print=js --highlight-level=heavy --pro=color --left-title=ITITLE1 --right-title=ITITLE2 -o temp.ps file.txt

That Should do it!!!!!!!!!!!!! Smilie
Enjoy
walforum

Last edited by walforum; 08-18-2011 at 01:45 PM..
# 6  
Old 12-05-2011
Sorry for the very late posting.
Quote:
Originally Posted by forumbaba
Hi,
I am converting a text file to ps using enscript.
Does anyone know how to print in color?

Here is what I tried:

enscript -ptemp.ps -G -F Souvenir-DemiItalic20 -f Souvenir-DemiItalic20 -E --color file.txt

The color doesn't work
Thanks
If you are using a Linux distribution look in /usr/share/doc/enscript (or possibly /usr/share/enscript-{ver} where {ver} is the version number. You will find a (possibly gzipped) file called README.ESCAPES. Use this to find out how to embed escape sequences into your text file to print in colour.

Andrew
Login or Register to Ask a Question

Previous Thread | Next Thread

2 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to change the background color in the init 3 mode(not line color)

Hello, I am using RHEL 6.1 on VMware I am searching for a way to change background color (not line by line color wich one can using tput command) basically changing the color of the whole screen to white instead of the default black and changing font color to black and alos would like to... (2 Replies)
Discussion started by: Dexobox
2 Replies

2. UNIX for Dummies Questions & Answers

Enscript

I'm trying to print a perlscript file from nedit using the enscript command. It reads as follows: enscript -dbigbird -R -G -b"my_perl_script.pl" This is the printer command line when I print from nedit. I also have the language set to perl under preferences. This allows me to view comments... (1 Reply)
Discussion started by: mirzabhai
1 Replies
Login or Register to Ask a Question