[comp.text.tex] Using a PostScript File from FrameMaker in LaTeX

hind@spunky.NYU.EDU (Michael Hind) (01/29/91)

Hi,
	I am trying to include a PostScript file produced by Framemaker
into a LaTeX document.  I have been using the Psfig macro (Version 1.3)
by Trevor Darrell, but am having some trouble.  I am able to compile
the document by running LaTeX, but when the document is printed (using
dvips), the printed version does not include anything from the PostScript
file; only the caption from my "figure" command is printed.

	Does anyone have any ideas what is happening?

Thanks in advance,
Michael Hind

hind@SPUNKY.CS.NYU.EDU (Michael Hind) (01/30/91)

From hind@SPUNKY.CS.NYU.EDU  Wed Jan 30 02:00:18 1991
Received: from SPUNKY.CS.NYU.EDU by cmcl2.NYU.EDU (5.61/1.34)
	id AA01356; Wed, 30 Jan 91 02:00:18 -0500
Received: by SPUNKY.CS.NYU.EDU (5.61/1.34)
	id AA09639; Tue, 29 Jan 91 22:03:40 -0500
Date: Tue, 29 Jan 91 22:03:40 -0500
From: hind@SPUNKY.CS.NYU.EDU (Michael Hind)
Message-Id: <9101300303.AA09639@SPUNKY.CS.NYU.EDU>
To: rnews@cmcl2.NYU.EDU

Path: spunky!hind
From: hind@spunky.NYU.EDU (Michael Hind)
Newsgroups: comp.text.tex
Subject: Using a PostScript File from Framemaker in LaTeX
Summary: A Question regarding the Subject
Keywords: Framemaker, PostScript
Message-ID: <hind.665093311@spunky>
Date: 28 Jan 91 20:08:31 GMT
Organization: New York University
Lines: 13

Hi,
	I am trying to include a PostScript file produced by Framemaker
into a LaTeX document.  I have been using the Psfig macro (Version 1.3)
by Trevor Darrell, but am having some trouble.  I am able to compile
the document by running LaTeX, but when the document is printed (using
dvips), the printed version does not include anything from the PostScript
file; only the caption from my "figure" command is printed.

	Does anyone have any ideas what is happening?

Thanks in advance,
Michael Hind

jdm5548@diamond.tamu.edu (James Darrell McCauley) (01/31/91)

FrameMaker PostScript is screwy! (Bug Frame Technologies.)
This is something that someone on the framers mailing list sent me
a while back. I haven't tried it though.  Usually, I just do an
X-window dump (or an !dc in maker) to get the image. Then I used
the PBMPLUS utilities to get a PostScript file.

---begin included message

Return-Path: <bochner@das.harvard.edu>
To: jdm5548@diamond.tamu.edu (James Darrell McCauley)
Return-Receipt-To: bochner@das.harvard.edu
Subject: Re: Using FrameMaker PostScript with PSfig/LaTeX 
In-Reply-To: Your message of Tue, 27 Nov 90 21:01:25 CST
Date: Wed, 28 Nov 90 10:18:20 -0500
From: Harry Bochner <bochner@das.harvard.edu>

Here's something (somewhat old) that I grabbed off USENET;
hope it helps, I haven't tried it ...
----------------
Article 7395 of comp.text:
From: jch@sppy00.UUCP (HANDLEY JOHN C)
Newsgroups: comp.text
Subject: Framemaker 2.0 PostScript in LaTeX
Date: 6 Jun 90 19:32:25 GMT
Reply-To: jch@sppy00.UUCP (HANDLEY JOHN C)
Organization: Online Computer Library Center, Dublin, Ohio.
Lines: 35

  I had some success in getting a Framemaker 2.0
  PostScript figure into LaTeX using
  ArborTex's dvips by doing the
  following:
   1) commenting out the showpage command in /FMENDPAGE
   2) commenting out the  xscale yscale stuff in /FMBEGINPAGE
      and putting my own scaling factors in.
   3) putting translate parameters in once I knew
      where LaTeX wanted to put the figure on the page.
   4) changed "1 1  612 792 0 1 2 FMDOCUMENT" to
      "1 1  360 360 0 1 2 FMDOCUMENT"
      since I had a 5 inch by 5 inch figure.
   5) changed "0 0 612 792 C" to "0 0 612 648 C"
      The C function appears to clip.  I simply
      adjusted on the the parameters so that it didn't
      chop out anything visible on the page.

 I'm sure some more rational and patient person can
 figure out how to do it right and consistently.

 Also, the X/NeWS tool pageview complains about these
 Framemaker PostScript files but is able to display them.

 Shame on Frame!

  John Handley
  jch@rsch.oclc.org
----------------

-- Harry Bochner
-- bochner@das.harvard.edu
-- 
James Darrell McCauley (jdm5548@diamond.tamu.edu, jdm5548@tamagen.bitnet)
Agricultural Visualization Lab, Department of Agricultural Engineering,
Texas A&M University, College Station, Texas 77843-2117, USA

rusty@belch.Berkeley.EDU (Rusty Wright) (01/31/91)

I asked Tom Rokicki for help on this and he couldn't get it to work
due to the wacky postscript output produced by Frame.  Apparently the
postscript header Frame uses does bad things.

jay@ctr.columbia.edu (Jay Hyman) (02/01/91)

Enclosed is a shell script which can create EPSF files out of standard 
single-page FrameMaker 2.0 documents in either portrait or landscape mode.
(It also accepts two other types of input files.)
It inserts (precomputed) bounding boxes corresponding to these two page sizes.
The output files can then be included in a LaTex document using the psfig 
macro.  Here at Columbia, we have found it relatively painless to include
Frame Maker figures in our LaTeX documents.
[BTW, we are using an old (1987) version of (Rokicki's ?) dvips, 
and it works just fine ... I hope newer versions work just as well...]

Three caveats: 
 1) For this filter to be effective, your figure needs to fill the
    entire page of the Frame maker document, because the figure will be shrunk 
    till the whole page fits in the space you allocate for the figure.

 2) The full Frame Maker PostScript prolog is included in each .ps file, and
    hence in each .eps file in this simple approach.  This makes for very slow
    printing if a paper contains a significant number of figures.  I looked
    briefly at the possibility of preloading the FM Dictionary and deleting the
    full prolog from all but the first such figure included in a  paper, but
    I gave up fairly briefly because I don't understand too much about how
    PostScript works and don't have the time to learn.  (If anyone out there who
    is more knowledgable wants to give it a shot...)

 3) As mentioned, this stuff is for the PostScript output from FrameMaker
    Version 2.0.  I don`t believe it works with 1.x, and I don't know about
    anything later.

Example usage: 
(Frame maker figure in landscape mode saved as fig.ps)

(command to shell...)
> psfilt fmland fig.ps fig.eps   # to create the eps file

(in LaTeX document:)
\begin{figure}[thb]
\centerline{\psfig{figure=fig.eps,height=4.5in}}
\caption{\label{fig:maker}
	 \protect{This figure was made by Frame Maker.}}
\end{figure}

And finally, here is the script, which was hacked together by 
Giovanni Pacifici, with some help from me,

Jay Hyman                                            jay@ctr.columbia.edu  
Center for Telecommunications Research                Columbia University



---------------------- cut here -----------------------
#!/bin/sh
#
# psfilt: filter to translate various PostScript files to EPSF
#
# Copyright (c) 1991, Giovanni Pacifici
#
# Permission is granted to copy and distribute this file in modified
# or unmodified form, for noncommercial use, provided (a) this copyright
# notice is preserved, (b) no attempt is made to restrict redistribution
# of this file, and (c) this file is not distributed as part of any
# collection whose redistribution is restricted by a compilation copyright.
#
trap 'echo interrupt; exit' 1 2 3 9 15
if test $# -ne 3
	 then 
		echo "This Program Translates Frame Maker, Mathematica and Splus"
		echo "PostScript Files into Encapsulated PostScript Files."
		echo "You can include these files directly into Latex Documents."
		echo "To Run The Filter use:"
		echo " "
		echo $0 "filetype InputFile OutputFile"
		echo " "
		echo "filetype can be one of the following:"
		echo "	fmland: Specifies that the input file is a Frame Maker"
		echo "		PostScript in Landscape Format"
		echo "	fmport: Specifies that the input file is a Frame Maker"
		echo "		PostScript in Portrait Format"
		echo "	Splus:	Specifies that the input file is a Splus"
		echo "		PostScript in Landscape Format"
		echo "	Math:	Specifies that the input file is Mathematica"
		echo "		PostScript"
		echo " "
		exit
 fi
case $1 in
fml*)
	echo "PostScript To EPSF Filter"
	echo "Converting Landscape Frame Maker File:" $2
	echo "Output to File:" $3
	cat $2 | \
	nawk '
	BEGIN { }
	{
		if ($0 ~ "^%%BoundingBox")
		{
			print $1 " 180 180 612 792"
		}
		if ($0 ~ " FMDOCUMENT")
		{
			print $1, $2 " 2 2 " $5, $6, $7, $8
		}
		if ($0 ~ " 1 FMBEGINPAGE")
			{
			print $1, $2 " 0 " $4
		}
		if ($0 !~ " 1 FMBEGINPAGE" && $0 !~ " FMDOCUMENT" && $0 !~ "^%%BoundingBox")
		{
			print $0
		} 
	}
		END {
		}
		' > $3 ;;
fmp*)
	echo "PostScript To EPSF Filter"
	echo "Converting Portrait Frame Maker File:" $2
	echo "Output to File:" $3
	cat $2 | \
	nawk '
	BEGIN { }
	{
		if ($0 ~ "^%%BoundingBox")
		{
			print $1 " 0 0 612 792"
		}
		if ($0 ~ " FMDOCUMENT")
		{
			print $1, $2 " 2 2 " $5, $6, $7, $8
		}
		if ($0 !~ " FMDOCUMENT" && $0 !~ "^%%BoundingBox")
		{
			print $0
		} 
	}
		END {
		}
		' > $3 ;;
Sp*)
	echo "PostScript To EPSF Filter"
	echo "Converting Landscape Splus File:" $2
	echo "Output to File:" $3
	cat $2 | \
	nawk '
	BEGIN { }
	{
		if ($0 ~ "^%%BoundingBox")
		{
			print $1 " 20 150 792 792"
		}
		if ($0 ~ "Landscape true def")
		{
			print $1, "false",  $3
		}
		if ($0 ~ "^/Region ")
		{
			print "/Region [20 150 792 792] def"
		}
		if ($0 !~ "Landscape true def"&& $0 !~ "^/Region " && $0 !~ "^%%BoundingBox")
		{
			print $0
		} 
	}
		END {
		}
		' > $3 ;;
ma*)
	echo "PostScript To EPSF Filter"
	echo "Converting Mathematica File:" $2
	echo "Output to File:" $3
	cat $2 | \
	nawk '
	BEGIN { }
	{
		if ($0 ~ "^%!")
		{
			print $0
			print "%%BoundingBox: 0 100 612 632"
		}
		else
		{
			print $0
		} 
	}
		END {
		}
		' > $3 ;;
*)
	echo 'unexpected name:' $1 ;;
esac
	

-- 
Jay Hyman                                            jay@ctr.columbia.edu  
Center for Telecommunications Research                Columbia University