change text color in postscript file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting change text color in postscript file
# 1  
Old 08-16-2011
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
# 2  
Old 08-16-2011
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.
# 3  
Old 08-16-2011
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
# 4  
Old 08-16-2011
Quote:
Originally Posted by walforum
I know it can be done with sed: However "what" do you change to "what"?
That depends on the current contents of the file, really.
# 5  
Old 08-16-2011
Of course it does, hehehe Smilie
# 6  
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!!!!!!!!!!!!!
Enjoy
walforum
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Change text color from echo command?

I have a bash script that starts and stops a game among other things through in.fifo and out.fifo In game the text comes out gray . Kinda hard to see in game window . I would like to change it to purple and maybe capitalize it. #!/bin/bash #nwservctl.sh cd... (5 Replies)
Discussion started by: 222222quick
5 Replies

2. Shell Programming and Scripting

Enscript text 2 postscript converter

I am trying to create a pdf file starting with a .eps file for the letterhead, and a text file to print on it. According to the man page the following should work. ^@epsf /home/aoti/coll07.eps ****** INVOICE ****** PAGE: 1 where ^@ is a... (0 Replies)
Discussion started by: jgt
0 Replies

3. Shell Programming and Scripting

Change text color in Korn shell to highlight Error

Hi this is my first post, so forgive me if what I'm requesting doesn't make sense. I'm connecting into a Unix server via SSH and using a Korn Shell (#!/bin/ksh). The Unix server has Oracle 11g installed on it and there are a number of scripts already setup to query the Oracle database to perform... (2 Replies)
Discussion started by: KeithJ
2 Replies

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

5. AIX

Printing Postscript files through Infoprint Manager to a Postscript printer

Hello, I am runnning Infoprint Manager 4.3 on AIX 5.2 . There is no problem printing AFP files, but I have hit a snag trying to use "AIX DSS" or "Other Printer" actual destinations to send unconverted Postscript files to native Postscript printers. The files are big, and they print correctly,... (0 Replies)
Discussion started by: ahetzel
0 Replies

6. Shell Programming and Scripting

Change color on another terminal

i already have a running and working script for remote connection. is there a way to change the terminal color everytime I ssh remotely to another server? this is to avoid confusion since I will be using only one server to remotely access around 50 servers (solaris, linux,. etc) (2 Replies)
Discussion started by: lhareigh890
2 Replies

7. Shell Programming and Scripting

color a figure in text file

Good morning, Can someone help to color a figure in columns if its exceeding a threshold using shell script . ex. I have file contains 5 columns showing a value in % I need to show the value in red if it exceed 90 % Appreciate your help (3 Replies)
Discussion started by: Bluetoot
3 Replies

8. Shell Programming and Scripting

Need to insert new text and change existing text in a file using SED

Hi all, I need to insert new text and change existing text in a file. For that I used the below line in the command line and got the expected output. sed '$a\ hi... ' shell > shell1 But I face problem when using the same in script. It is throwing the error as, sed: command garbled:... (4 Replies)
Discussion started by: iamgeethuj
4 Replies

9. UNIX for Dummies Questions & Answers

How to change the font or color of text

Hi Gurus, I have a small requirement where i want to change the color & font of some text in a file. i have a file error.txt which will be created in the script using egrep. After that iam adding these lines at head & tail to that file using the following code awk 'BEGIN{print"Please... (4 Replies)
Discussion started by: pssandeep
4 Replies
Login or Register to Ask a Question