[comp.unix.aix] How to use Display PostScript to preview PS?

jonathan@cs.pitt.edu (Jonathan Eunice) (01/05/91)

How does one use DPS to preview PostScript files?  I can execute
PostScript code that I hand-type by using the program
/usr/lpp/DPS/bin/dpsexec, but I have yet to find a way of getting it to
read a pre-created PostScript file.  Is there some way that I'm
missing, or some other preview program I've overlooked?  Or must I hack
the /usr/lib/DPS/examples/dpsexec source to add a "read from file"
option?

jonathan@speedy.cs.pitt.edu (Jonathan Eunice) (01/05/91)

In my last missive, I asked "How does one use DPS to preview PostScript
files?" GRAVISHANKER@EAGLE.WESLEYAN.EDU responed by mail with the
embarrasingly simple:

|  Have you tried using the input redirect?
|
|	dpsexec < myfile.ps
| 
|  dpsexec has problems, if I remember right, in that if you are previewing
|  multi-page output, it would show only the last page. Redefine the showpage
|  macro (Of course, first save the system one to a different name) to wait for
|  some input to get around this. 

NB, the showpage macro is the trick.  Don't redefine it and the image will
display and dpsexec will exit so fast you don't even see it.  Thanks,
Ravi, for the insight.

So, dpsexec will work, but is not terribly good, for multi-page docuemnts
eg.  Does anyone know of a good PS previewer based on DPS and X?  

jonathan@speedy.cs.pitt.edu (Jonathan Eunice) (01/05/91)

For those of you that do not want to figure out how to redefine 
the showpage operator to pause for input just to get dpsexec to work,
the following PostScript fragment may be helpful.  Put it in a file,
say showpage.ps, and run it before trying to preview PS files.
Whenever the PostScript interpreter runs into a showpage command, it
will pause for a character of input, such as space or return.  Thus
multi-page files can be viewed.

----------- showpage.ps ----------- 
/wait-for-input {
	{ (%stdin) (r) file read	% read from stdin
		{pop exit}			% if char avail, pop and exit
		{exit}			% otherwise EOF, just exit
		ifelse
	} loop				% wait for exit
} def

userdict /oldshowpage			% prepare to add to userdict
systemdict /showpage get		% get guts of showpage routine
put					% oldshowpage now available

/showpage { wait-for-input		% redefine showpage to wait
	    oldshowpage
} def
----------- showpage.ps ----------- 

It would be nice to be able to say

$cat showpage.ps mypostscriptfile.ps | dpsexec

and have that work.  Unfortunately, dpsexec exhibits strange behavior
when I've tried this.  [Anyone who can explain this, I'm curious.]  The
PS run command works considerably better than I/O redirection.  If you
use run, note that it expects absolute pathnames.  Eg:

$dpsexec
PS>(/usr/lpp/DPS/showpage.ps) run
PS>(/usr/lpp/DPS/mypostscriptfile) run

johnsen@bcstec.boeing.com (Brian Johnsen) (01/05/91)

In article <9632@pitt.UUCP> jonathan@cs.pitt.edu (Jonathan Eunice) writes:
>How does one use DPS to preview PostScript files?  I can execute
>PostScript code that I hand-type by using the program
>/usr/lpp/DPS/bin/dpsexec, but I have yet to find a way of getting it to
>read a pre-created PostScript file.  Is there some way that I'm
>missing, or some other preview program I've overlooked?  Or must I hack
>the /usr/lib/DPS/examples/dpsexec source to add a "read from file"
>option?

Get into the DPS window where you can enter PostScript commands
interactively.  ( with a prepared file handy somewhere ) and at the
prompt you can enter :

PS> (~/hand_created_postscript_filename) run

The run command will interpret the string in the parens as a filename.
I have only been able to run files relative to my $HOME however.
I've started up DPS in the directory where the PS file is, but still have
to feed DPS ($HOME/Ps/filename.ps) to get from here to there.

marc@ibmpa.awdpa.ibm.com (Marc Pawliger) (01/05/91)

In article <9632@pitt.UUCP>, jonathan@cs.pitt.edu (Jonathan Eunice) writes:
|> How does one use DPS to preview PostScript files?  I can execute
|> PostScript code that I hand-type by using the program
|> /usr/lpp/DPS/bin/dpsexec, but I have yet to find a way of getting it to
|> read a pre-created PostScript file. 

dpsexec is just the interactive version of the PostScript interpreter.
You can use the PS command 'run' to read from a file like so:

  % /usr/lpp/DPS/bin/dpsexec
  PostScript(r) Version 1006.6
  Copyright (c) 1984, '85, '86, '87, '88, '89 Adobe Systems Incorporated.
  Typefaces Copyright (c) 1981 Linotype AG and/or its subsidiaries.
  All Rights Reserved.
  PS> (/path/to/the/file.ps)run

Check out the PS "red book" for more details.

+---Marc Pawliger---IBM Advanced Workstations Division---Palo Alto, CA---+
|    Internet: marc@ibminet.awdpa.ibm.com    VNET:    MARCP at AUSVM6    |
|     UUCP:     uunet!ibmsupt!ibmpa!marc      Phone:   (415) 855-3493    |
+------IBMinet:  marc@ibmpa.awdpa.ibm.com------IBM T/L:  465-3493--------+

These are my opinions, not IBM's etc etc etc

gravishanker@eagle.wesleyan.edu (01/05/91)

In article <592@bcstec.boeing.com>, johnsen@bcstec.boeing.com (Brian Johnsen) writes:

> I have only been able to run files relative to my $HOME however.
> I've started up DPS in the directory where the PS file is, but still have
> to feed DPS ($HOME/Ps/filename.ps) to get from here to there.

You are correct in that I always have to give the complete pathname for it to
work. This way, files that are not under $HOME can also be viewed.

Ravi

hucka@engin.umich.edu (Michael Hucka) (01/08/91)

In article <9635@pitt.UUCP> jonathan@speedy.cs.pitt.edu (Jonathan Eunice) writes:
   From: jonathan@speedy.cs.pitt.edu (Jonathan Eunice)
   Date: 4 Jan 91 22:46:14 GMT

   For those of you that do not want to figure out how to redefine 
   the showpage operator to pause for input just to get dpsexec to work,
   the following PostScript fragment may be helpful.  Put it in a file,
   say showpage.ps, and run it before trying to preview PS files.
   Whenever the PostScript interpreter runs into a showpage command, it
   will pause for a character of input, such as space or return.  Thus
   multi-page files can be viewed.

   [... rest deleted ...]

Jonathan, thanks very much for posting this.

I have a followup question: with this patch I've been able to use dpsexec to
view postscript generated from latex files.  However, the text is nearly
unreadable.  Of course this is due to mismatch between the screen resolution
and the resolution at which dpsexec is trying to display the fonts.
Question: is there a way, in PostScript, to improve dpsexec's output of the
fonts?  (Excuse me if that is a terribly naive question.)  Basically I'd like
to see a prolog file which redefines showpage and fixes up the font output so
that I could use dpsexec to preview output from dvips.

What I suspect will really be necessary is to generate the DVI output from
latex for different-resolution fonts, to match the RS/6000 monitor's
resolution, but I wanted to ask on the net, in case some of you gurus have a
simpler solution.

Mike
--
Mike Hucka                     | Internet: hucka@caen.engin.umich.edu    
University of Michigan AI Lab  | 1101 Beal Ave., Ann Arbor, MI 48109