[comp.lang.postscript] Help with eroff and postscript

mark@gizzmo.UUCP (mark hilliard) (07/23/89)

Well, I like eroff, and have found the man set very good untill now, but
I am stumped.  Can anyone shed some light on this?

Ok,  I have a standard text file written with the mm macros, pic, and tbl
sections.  Now, I would like to include a postscript segment at the TOP
of my file, and then send the entire thing through eroff to a postscript
printer.  Although this is not important, my command line will look
something like this:

tbl file | pic -D | eroff -mm -dps

The man on page 2-13 says that I have to append 
the \X'code="postscriptline"' stuff to EACH line in my postscript file
that I want to include in my troff file (up to 80 chars per line max).
This is NOT acceptable, as I do not wish to have to modify EACH and 
EVERY line of my postscript include file. 

IS THERE ANY EASIER WAY TO DO THIS????

Can I add my postscript file into header file (must be there for eroff
somewhere) that eroff (must?) send to the postscript printer with
the -dps command?  And if this is possible, is there someway to 
specify via command line option which header file to use?


-- 
Mark Hilliard                            {ethos,fthood,u1100a}-----\
   N2HHR                                rutgers!rochester!kodak!pcid!gizzmo!mark
                                                                \-->gizzmo!mark

cortesi@infmx.UUCP (David Cortesi) (07/24/89)

In article <374@gizzmo.UUCP> mark@gizzmo.UUCP (mark hilliard) writes:
>
>Ok,  I have a standard text file written with the mm macros, pic, and tbl
>sections.  Now, I would like to include a postscript segment at the TOP
>of my file, and then send the entire thing through eroff to a postscript
>printer.
>   [details elided]
>Can I add my postscript file into header file (must be there for eroff
>somewhere) that eroff (must?) send to the postscript printer...?

I had the same need, to add a new function definition to the postscript
prolog that eroff puts at the head of the output file.  After battling
Chapter 2 of the eroff manual a while I called Elan tech support and was
given this undocumented gimmick:

      \!!prologcode@pathname...

for example

      \!!prologcode@/usr/fred/personal.ps.defs

This has to be processed before any text; i.e. it can follow macro
definitions and other dot commands so long as it comes before any output
data is generated.  Write the output file to disk instead of the printer
and examine it to make sure the code goes where you want it go.

By the way, since this IS undocumented, don't blame me if they drop
it next release - but for now it works pretty well.

///////   /     David Cortesi               {pyramid|uunet}!infmx!cortesi
//////   //                              ///////////////////////////////////
////  / ///     Informix Software        //                               // 
///  / ////     4100 Bohannon Drive      //      (aphorism goes here)     //
//  / /////     Menlo Park, CA  94025    //                               //
/  ////////     (415) 926-6300           ///////////////////////////////////

root@yclept.chi.il.us (Root) (07/24/89)

In article <374@gizzmo.UUCP>, mark@gizzmo.UUCP (mark hilliard)
writes (I extracted the material I wanted to respond to):
> Ok,  I have a standard text file written with the mm macros, pic, and tbl
> sections.  Now, I would like to include a postscript segment at the TOP
> of my file, and then send the entire thing through eroff to a postscript
> printer.  Although this is not important, my command line will look
> something like this:
> 
> tbl file | pic -D | eroff -mm -dps
> 
> The man on page 2-13 says that I have to append 
> the \X'code="postscriptline"' stuff to EACH line in my postscript file
> that I want to include in my troff file (up to 80 chars per line max).
> 
> IS THERE ANY EASIER WAY TO DO THIS????
> 
> Can I add my postscript file into header file (must be there for eroff
> somewhere) that eroff (must?) send to the postscript printer with
> the -dps command?  And if this is possible, is there someway to 
> specify via command line option which header file to use?
> 
> -- 
> Mark Hilliard                            {ethos,fthood,u1100a}-----\
>    N2HHR                                rutgers!rochester!kodak!pcid!gizzmo!mark
>                                                                 \-->gizzmo!mark


I do not know what version of Eroff you are talking about.  I am talking about
Eroff version 2.2 for UNIX.  The machine is an AT&T UNIXpc.

Use the .cL, .cR, .cC, or .cS graphics inclusion macros as documented on page
2-1.

To get the graphic (Postscript code) at the beginning of your material, note
the sentence just before the "A.3 GRAPHICS/CODE INCLUDE RESTRICTIONS" header
on page 2-4.

	"If no text has been output yet, you may force the image to be
	output before any text by calling the .fI macro.  This will cause
	the image to be output without a text line above it."

I have discovered that the following works:

	.P! postscriptfile
	.fI

The purpose of \X'code="postscriptline"' is to be imbedded in your Eroff code
to emit the "postscriptline" code into the generated Postscript.  It is not
a 'wrapper' for each line of your Postscript code.

The Postscript code inserted by either method is enclosed in a 'save' and
'restore' pair.  This is easy enough to escape; start your code with a
'restore' and end it with a 'save'.

Or you can include your custom prologue code with either of the following lines
before any text (not macros) in Eroff input:

	\X'prologcode="short piece of Postscript code"'

or
	\X'prologcode@file'

You should replace "file" with your own file name.

As both of these methods are documented (chapter 2: pages 12 to 14), I do
not expect them to go away in the 'next release.'  This last comment is in
response to message id <1893@infmx.UUCP>.

This is material I learned last night by reading the manual and experimenting
with my new printer.  I was wanting to put logos first on letters.

	Randolph J. Herber,
	@ home: {att|amdahl|clout|mcdchg|laidbak|obdient|wheaton}!yclept!rjh,
		rjh@yclept.chi.il.us

UNIX is a registered trademark of AT&T Corporation.
Postscript is a registered trademark of Adobe Corporation.

arne@yc.estec.nl (Arne Lundberg) (07/25/89)

In article <1893@infmx.UUCP> cortesi@infmx.UUCP (David Cortesi) writes:
>Chapter 2 of the eroff manual a while I called Elan tech support and was
>given this undocumented gimmick:
>
>      \!!prologcode@pathname...
>
>By the way, since this IS undocumented, don't blame me if they drop
>it next release - but for now it works pretty well.

They have not dropped it, they changed the syntax to

	\X'prologcode@pathname'

and DOCUMENTED it. This is based on EROFF Release 2.2 for Unix.


Arne Lundberg

European Space Technology Centre, Noordwijk, the Netherlands
arne@yc.estec.nl or ALUNDBER@ESTEC.BITNET
Phone: +31 1719 84865, Fax: +31 1719 12142, Telex: 39098

tony@oha.UUCP (Tony Olekshy) (07/26/89)

In message <1893@infmx.UUCP>, cortesi@infmx.UUCP (David Cortesi) writes:
> 
>       \!!prologcode@pathname...
>
> By the way, since this IS undocumented, don't blame me if they drop
> it next release - but for now it works pretty well.

Quickly consults Eroff revision 870818 manual, finds prologcode documented
on page 2-2 in Eroff extended features section, considers issue RTFM...

Yours, etc., Tony Olekshy (...!alberta!oha!tony or tony@oha.UUCP).

jlo@elan.elan.com (Jeff Lo) (07/27/89)

In article <1032@esatst.yc.estec.nl> arne@esatst.UUCP (Arne Lundberg) writes:
>In article <1893@infmx.UUCP> cortesi@infmx.UUCP (David Cortesi) writes:
>>Chapter 2 of the eroff manual a while I called Elan tech support and was
>>given this undocumented gimmick:
>>
>>      \!!prologcode@pathname...
>>
>>By the way, since this IS undocumented, don't blame me if they drop
>>it next release - but for now it works pretty well.
>
>They have not dropped it, they changed the syntax to
>
>	\X'prologcode@pathname'
>
>and DOCUMENTED it. This is based on EROFF Release 2.2 for Unix.

As it turns out, the \!!prologcode ... should be used, rather than
\X'prologcode ...' for PostScript, because by the time troff outputs
the pass-through to the driver with \X it has already started emitting
positioning commands.  When the PostScript driver sees any positioning
or text commands it closes out the prolog and starts working within a
save/restore context for the first page, and any additions to the
prolog are disallowed.  The \!! pass-through is totally transparent,
and no formatting commands are output before it *if* the \!! commands
are at the beginning of the source file.  This way the driver will
see the prologcode command before it has closed out the prolog and
the PostScript code will be added to the prolog.  Unfortunately, the
Eroff release 2.2 manuals had been printed before all of the code had
been finalized, and for this reason we are leaving the (currently
undocumented) \!! command in Eroff, and it will be re-documented in
later revisions of the manual.  The \!!prologcode usage has been
documented in the Eroff 2.2 READ.ME file for the last year or so.
Further questions should be directed to the Elan support staff or
to me (support@elan.com or jlo@elan.com).  Thanks.
-- 
Jeff Lo, Elan Computer Group, Inc.
jlo@elan.com, ..!{ames,uunet}!elan!jlo
888 Villa Street, Third Floor, Mountain View, CA 94041, 415-964-2200

kg@elan.elan.com (Ken Greer) (07/27/89)

>>I called Elan tech support and was given...
>>
>>      \!!prologcode@pathname...
>>
>>By the way, since this IS undocumented, don't blame me if they drop
>>it next release - but for now it works pretty well.
> 
> They have not dropped it, they changed the syntax to
> 
> 	\X'prologcode@pathname'
> 
> and DOCUMENTED it. This is based on EROFF Release 2.2 for Unix.

In the latest rev of our manual, both forms are included.
Both syntaxes are supported in release 2.2 and will indeed
continue to be supported in the future.

With prologcode, the 1st version with \!! is actually preferable
because \X can spit our some positioning stuff first that you might
not want when you do a prologue.

The READ.ME file included with all Eroff distributions discusses this.

And here I though people never read computer manuals! ;-)

Ken Greer  Elan Computer Group, Inc. 888 Villa St. 3rd Floor Mt View CA 94041
Phone:     415-964-2200
Internet:  kg@elan.com
UUCP:      {ames,hplabs,uunet}!elan!kg

cortesi@infmx.UUCP (David Cortesi) (07/27/89)

In article <1032@esatst.yc.estec.nl> arne@esatst.UUCP (Arne Lundberg) writes:
>In article <1893@infmx.UUCP> cortesi@infmx.UUCP (David Cortesi) writes:
>>Chapter 2 of the eroff manual a while I called Elan tech support and was
>>given this undocumented gimmick:
>>      \!!prologcode@pathname...
>>By the way, since this IS undocumented, don't blame me if they drop
>>it next release - but for now it works pretty well.
>
>They have not dropped it, they changed the syntax to
>	\X'prologcode@pathname'
>and DOCUMENTED it. This is based on EROFF Release 2.2 for Unix.

Not quite.  I am familiar with the three documented ways of putting
postscript into eroff output, as given in chapter 2 of the manual for
eroff 2.2.  They are:

	\X'code="any postscript one-liner"'
	\X'code@pathname_of_ps_code_file'
	\X'prologcode@pathname_of_ps_defs_file'

I have used the first two successfully; they are for in-line code. 
The third, for defining new functions in the header, will not work for me;
no matter where in the source file or macro libraries I put it, it returns
the error message:

	Warning: PostScript prolog code must be at beginning of file
	Code @ "pathname_from_command"  ignored

After struggling with it, I called the ever-helpful Elan tech support
crew, and was given the undocumented escape code \!!prologcode@pathname
as a work-around.  It worked where the \X escape did not.  I repeat,
I have no assurance that Elan means to support this, or document it,
or fix \X'prologcode', or what.  If \X works for you, you should use it. 
If not, you can try \!! .

///////   /     David Cortesi               {pyramid|uunet}!infmx!cortesi
//////   //                              ///////////////////////////////////
////  / ///     Informix Software        //                               // 
///  / ////     4100 Bohannon Drive      //      (aphorism goes here)     //
//  / /////     Menlo Park, CA  94025    //                               //
/  ////////     (415) 926-6300           ///////////////////////////////////