From: sievers@AGPS.LANL.GOV (Cindy Sievers)
Subject: Summary: Importing a PostScript file (long)
Organization: The Internet
Distribution: inet
Date: 14 Apr 92 15:28:16 GMT

First of all - thank you to everyone who replied,  I'm impressed with
the wealth of information that I received through this group.

My original question was:

>A PostScript file from a Framemaker document was created by "Printing 
>only to file" from the File/Print menu.  Later, the original Framemaker
>document was deleted (without a .backup but that's another story). 
>Is it possible to convert that PostScript file back into a 
>Framemaker Document?

To summarize all of the responses:

>No

It appears that this is just not possible.  The original file was
a graphical illustration created in Framemaker containing only 
text labels, so retaining text will not be of much help. BUT, I
did learn (painfully) the real value of backups! 
 
Since I received a couple of requests to summarize, listed below are 
all of the responses received:

------------------------------------------------------
From: drd!mark@tulsun.central.sun.com (resident.alien)

in a word, no.  Hang on to that postscript file.
------------------------------------------------------
From: drf@frame.com (David Fuchs)

You can get the basic text back, but without the formatting, and none of the
graphics.  Just open the PS file as a text file, and start editing...
----------------------------------------------------------------------------
From: Paul_Berry@next.com

I don't think it's possible. Too much information has been lost. You could  
recover the words of the text, but all the Frame tags and format definitions  
would be lost.

(I take it you've tried opening the PostScript file as a document?
Once you get past oodles of font description stuff it's usually fairly easy to  
identify the text itself. Assuming that you have an ASCII postscript file, and  
not a compressed one, which would just look like pages of haxadecimal)

Are you working on Macintoshes? I suspect that your better bet is (ASAP!  
before tracks are written over) to get a deleted-file recovery program and try  
to recover the deleted Frame files. If you are using autosave, there may be  
dozens of intermediate autosaves that have been created and then deleted.

But perhaps some one else on the net knows something more encouraging about  
reverse-engineering the postscript.
-----------------------------------------------------------------------------
From: "Mike Sierra" <mike_sierra@macmailgate.ora.com>

Oh, Lord-- I hope not!  That's not the purpose of PostScript.  There's no way
to "convert" the files back that I know of, meaning back to a structured
document containing formatting information.  There are ways of retrieving the
pure ASCII text, however, which you can then reformat.  There are probably two
options, both very messy:

1) Print out the PostScript files and scan them back in using optical character
recognition software.  OCR software is still pretty dumb, and has a high error
rate.  I suspect the time involved would be roughly equivalent to typing it
back in by hand.  

2) Look at the PostScript file and try to determine where the text is
described.  Some formatting packages, such as troff, create PostScript that
describes where each word, or even pair of characters, is on the page.  Here's
an awful sample:  

806(,)s
10 pt CR N
826(X)s
827(XG)s
853(Ge)s
879(et)s
905(tW)s
931(Wi)s
957(in)s
983(nd)s
1009(do)s
1035(ow)s
1061(wA)s

Frame, however, thinks in PostScript, so each line of text as it appears in the
file is preserved in the PostScript file.  Here's an excerpt that describes
specific lines of text:

(International Order Department) 314.67 431.43 T
(Jacob Way) 314.67 421.43 T
(Reading, MA  01867  U.S.A.) 314.67 411.43 T
(Telephone: 1-617-944-3700) 314.67 401.43 T
(FAX: 1-617-942-2829) 314.67 391.43 T
(ASIA except JAPAN \050inquiries\051) 314.67 371.43 T
(Addison-Wesley \050Singapore\051 Pte. Ltd.) 314.67 361.43 T
(15 Beach Road) 314.67 351.43 T
(05-09/10 Beach Centre) 314.67 341.43 T
(SINGAPORE 0718) 314.67 331.43 T
(Telephone: 65-339-7503) 314.67 321.43 T
(FAX: 65-339-9709) 314.67 311.43 T

So, if you know how to use sed scripts or some other way of doing batch text
processing using metacharacters, you could write a script that strips out all
the PostScript verbosity and keeps the text, relying on the fact that text is
enclosed within parentheses.  You'd typically do this with sed, vi, or emacs on
a UNIX system, but you can even do it on a Mac with Nisus, which supports
regular expressions.  Frame's "Use Wildcards" is not quite up to the task, due
to way it handles wildcards-- ordinarily )*$ means any number of characters
that appear between a close paren and the end of the line.  In Frame, it's any
number of characters in a *single word*.

>From there you'll have to hack the text back into shape in Frame-- deleting the
artificial line breaks, formatting the document, converting those backslash
codes back to the special characters they represent, etc.  Like I said, it's
definitely not a clean solution.  I'm sure you've already been chided about the
importance of backing up your disk, so I won't go into that...

Let me know if this is all gibberish...

----------------------------------------------------------------------------
From: brown@wi.extrel.com (Vidiot)

The major problem here is that you don't appear to be backing up your files.
If you were doing that you would be able to recover the file from the backup
tape.  The exception to this is if the file was created and deleted all in the
same day.  Then you have my pity.

Why my pity?  Because you can't read a PostScript file into FrameMaker and
make a new FrameMaker editable file.  You are going to have to enter the
whole document from scratch.  Hey, at least you have the printed file to
go by :-)
-------------------------------------------------------------------------------

From: melasv!prashant@uunet.uu.net (Prashant Avashia)

Something occured to me, though quite elementary. If the original Framemaker document was created maybe a day or so before it was deleted, you may ask your
systems administrator/manager/whosoever to restore it for you from the
last backup tape.

However, if the original ducument was created on the same day, that it was
deleted, then it is another story.
----------------------------------------------------------------------------
From: webb+@cs.cmu.edu (Jon Webb)

Please don't take this as a snide comment, but when I was little I
took apart an electric motor and unwound the copper wire all over the
place.  After I was done, I asked my father to help me put it back
together, and he told me the story of the little boy who wanted to put
an oak tree back into the acorn that it grew from.

There's no way to do what you want.  The only thing you can do is type
the document back in by hand.  Or you could edit the postscript file
and recover some of the text of the document, then import it into
Frame as a text file and add the formatting by hand.  But it might be
easier to start from scratch, if you can type well.
------------------------------------------------------------------------------
From: Henry Budgett <henryb@sco.com>

There is one way to get it back - print the PostScript file and 
then OCR the resulting pages. Save a lot of typing!
------------------------------------------------------------------------------
From: Owen Rees <rtor@ansa.co.uk>

It is possible to generate a framemaker document from postscript but
it would require a lot of effort to write the necessary conversion
program and the result would not be the original document, just a
document that looks the same when printed. There is no way to
reconstruct paragraph tags or the structure of graphics.

How much of the process is worth automating depends on how big the
document is and whether or not it follows a particular style
throughout.

It is not difficult to write a program that extracts the text. If the
document contains numbered sections it is not too hard to apply
various heuristics to guess what paragraph tags to use when generating
MIF output. I would recommend PERL since it has good pattern matching
and string processing facilities.

Unless you are talking about tens of thousands of pages with a lot of
diagrams, it is not worth going beyond a simple text reconstructor.
(We used to use Xerox Viewpoint which has no useful compatibility
features. We thought about writing an Interpress->MIF converter -
about the same complexity as PS->MIF - but decided it was not worth it
for the few hundred documents we needed to convert.)

Here is a little text extractor - very crude but easy to improve.

#!/usr/bin/perl

  while (<STDIN>)
  { if (($text,$x,$y) = /^\(([^)]*)\)\s+(\d+\.\d*)\s+(\d+\.\d*)\s+T$/)
      { $out = "$text\n\n"; }
    elsif (($text,$x,$y) = /^-?\d+\.\d*\s+\(([^)]*)\)\s+(\d+\.\d*)\s+(\d+\.\d*)\s+P$/)
      { $out = "$text\n"; };
    if ($out)
    { $out =~ s/\\050/\(/g;
      $out =~ s/\\051/\)/g;
      print $out;
      $out = "";
    };
  };
exit 0;
------------------------------------------------------------------------------
From: John Bayle <johnb@kbss.bt.co.uk>

Sorry to state the obvious, but if the platform is networked, perhaps
someone else (sysman) backed it up!

On the other hand, if it's mainly text and the platform is unix then:

grep '(.*)' | sed 's/^[^(]*(\([^)]*\)).*$/\1/' 

will get all the strings out. I'm sure someone else can refine this do
do even more! Note that a reverse-collating printout has pages reversed.
-------------------------------------------------------------------------------