[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ps export/import

Hi all,

   after struggling with this for ages and a whole day, I finally
figured out a way to import ps files generated with IDL into word
processing software such as StarOffice or Word. The trouble came
(a) I usually don't generate postscript with /ENCAPSULATE in IDL, so
my files are missing the EPSF-3.0 label in the first line
(b) I generate a lot of landscape plots which come out rotated in IDL

   as a brave guy (but only after browsing through newsgroup archives
;-), I decided it should be possible to delete the rotate statement in
the ps file without destroying the file. Turns out one has to delete a
few more things as well: all bounding boxes, the page orientation and
a translate statement. If, thereafter, the honored user sends the
crippled file through ps2epsi (viva Unix ;-) she will have a perfect
encapsulated file including a preview image.

Attached is a small shell script which automates this process:

psfix filename [outfilename]

If outfilename is not given it will be the basefilename of filename +

Good night,


[[ Dr. Martin Schultz   Max-Planck-Institut fuer Meteorologie    [[
[[                      Bundesstr. 55, 20146 Hamburg             [[
[[                      phone: +49 40 41173-308                  [[
[[                      fax:   +49 40 41173-298                  [[
[[ martin.schultz@dkrz.de                                        [[
# shell script to fix postscript files that were generated in IDL
# with landscape orientation to create epsi files that can be 
# imported into StarOffice
# Author: Martin Schultz, MPI, 04 Jan 2001
# The output file will be <filename>.eps unless otherwise specified

# check arguments

if [ .$1. == .. ] ; then
   echo Usage: psfix inputfile [outputfile]
echo Converting $infile

if [ ! -s $infile ] ; then
   echo Input file $infile not found!

if [ .$2. == .. ] ; then
   outfile=`basename $infile .ps`.eps
echo generating EPS file $outfile

# remove bounding box and orientation statements
sed 's/%%BoundingBox:.*//' $infile > tmp___001.ps
sed 's/%%PageOrientation: Landscape//' tmp___001.ps > tmp___002.ps
rm -f tmp___001.ps
sed 's/%%PageBoundingBox:.*//' tmp___002.ps > tmp___003.ps
rm -f tmp___002.ps

# remove rotate and translate statements
sed 's/[0-9 ]*translate//' tmp___003.ps > tmp___004.ps
rm -f tmp___003.ps
sed 's/[0-9 ]*rotate//' tmp___004.ps > tmp___005.ps
rm -f tmp___004.ps

# convert to epsi
ps2epsi tmp___005.ps
rm -f tmp___005.ps

# rename
mv tmp___005.epsi $outfile
rm -f tmp___005.epsi