Article View: comp.lang.postscript
Article #1584Simply encapsulating an ASCII file
From: Bernie Cosell
Date: Mon, 22 Jan 1990 04:05
Date: Mon, 22 Jan 1990 04:05
73 lines
2358 bytes
2358 bytes
I asked a couple of days ago about some simple way to get an EPS version of a
plain ASCII file. After fooling, unsuccessfully, with enscript for a while,
I decided to just leap in and fix it up brute force. Attached is a little
shell script that'll get you a PostScript rendering [that \psfig likes, which
is what I was after in the first place!].
__
/ ) Bernie Cosell
/--< _ __ __ o _ BBN Sys & Tech, Cambridge, MA 02238
/___/_(<_/ (_/) )_(_(<_ cosell@bbn.com
#!/bin/sh
# $Header: encapsulate,v 1.1 90/01/21 17:33:42 cosell Exp $
# Encapsulate a simple ASCII file. It is assumed that you just want the
# file to be PostScripted 'as is', without anything fancy like page breaks
# or the like.
pgm=`basename $0`
Usage="$pgm ASCIIfile"
case $# in
1) ;;
*) echo >&2 "Usage: $Usage"
exit 1
;;
esac
file=$1
if [ ! -r $file ]
then
echo >&2 "$pgm: Can't find \"$file\""
exit 1
fi
# First off, figure out how long the file is [gives us Y value for bounding
# box]
lines=`set \`wc -l $file\`; echo \$1`
# Now find the longest line [for giving us the X value for BB]
linelength=`awk "BEGIN { max = 0 }
{ if (length > max)
{
max = length
}
}
END { print max }" $file`
height=`expr $lines \* 12`
width=`expr \( $linelength \* 72 + 9 \) / 10`
cat <<PREAMBLE
%!
%%Title: $file
%%CreationDate: `date`
%%BoundingBox: 0, 0, $width, $height
%%EndComments
/Courier findfont 12 scalefont setfont
/S { 3 1 roll moveto show } bind def
PREAMBLE
sed 's/\\/\\\\/g
s/(/\\(/g
s/)/\\)/g' < $file \
| awk "{ if (length > 0)
{
printf \"%d %d (%s) S\n\", 0, ($lines - NR) * 12, \$0;
}
}"
Technical Details
Message-ID:
<51196@bbn.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!think!snorkelwacker!apple!bbn!bbn.com!cosellShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!think!snorkelwacker!apple!bbn!bbn.com!cosell From: cosell@bbn.com (Bernie Cosell) Newsgroups: comp.lang.postscript Subject: Simply encapsulating an ASCII file Message-ID: <51196@bbn.COM> Date: 22 Jan 90 04:05:34 GMT Sender: news@bbn.COM Reply-To: cosell@BBN.COM (Bernie Cosell) Organization: BBN Systems and Technologies, Inc, Cambridge MA Lines: 73