change text color in postscript file

Hi everyone,
I have a program that produces postscript files on the fly
The color of the files produced are in black and white

I want to change the text color of postscript file as the file is being produced without having to manually go into the ps file and change it myself.

Any Ideas?
Thanks

If it's just a simple change of some text to another, that can be done with sed. You'd have to post an example of what you'd want changed.

I know it can be done with sed: However "what" do you change to "what"?
If you are familiar with ps file syntax please give an example.
Thanks

That depends on the current contents of the file, really.

Of course it does, hehehe :slight_smile:

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

  1. 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

  2. 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

  1. 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!!!!!!!!!!!!!
Enjoy
walforum