cracraft@venera.isi.edu (Stuart Cracraft) (01/23/88)
Is there a way to embed post-script images in troff text? For example, the postscript language could be used to produce a fancy table or image, and this postscript language and/or image could somehow be inserted in the middle of a troff document. Stuart
tim@ora.UUCP (Tim O'Reilly) (02/03/88)
In article <4594@venera.isi.edu>, cracraft@venera.isi.edu (Stuart Cracraft) writes: > Is there a way to embed post-script images in troff text? > For example, the PostScript language could be used to produce > a fancy table or image, and this PostScript language and/or > image could somehow be inserted in the middle of a troff > document. > It depends on the postprocessor you're using. To include PostScript code in troff is simply a matter of using any one of a number of troff mechanisms. For example, there's so called "transparent output": \! PostScript code here Or there's the .cf request to interpolate the contents of an entire file, uninterpreted, into the troff output stream: .cf file.ps Or there's the .sy request, which runs a program an interpolates its output, uninterpreted, into the troff output stream: .sy cat file.ps In addition, Berkeley ditroff includes a special escape sequence, \X, which allows you to include in-line code: \X 'PostScript code' Of course, when you do any of these things, you must make allowances, in troff, for spacing and so forth, so troff and the output device don't get out of sync! For example, if you are going to interpolate the contents of a PostScript file containing a figure, you must tell troff to space down, or else it will resume printing at the original position, right on top of the figure. The real problem, though, is whether or not your troff-to-PostScript postprocessor will let the code go through. For example, versions of transcript prior to 2.0 don't support this. In current versions of transcript (that is, of psdit, the ditroff-to-PostScript translator that is part of transcript), the % sign can be used to signal psdit that the following lines contain PostScript code that is to be passed uninterpreted to the printer. This situation is terminated by a line containing a single . For example: \!% \!PostScript code here \!. There get to be some complications with saving and restoring the graphics state....how well this works depends on whether or not your PostScript code interferes with the PostScript being generated by psdit. To make things easier, they've defined some additional PostScript operators (PB--Picture Begin--and PE--Picture End) to make things easier. The full example documented on the psdit man page looks like this: \& .fl \!%PB \!/showpage{}def .fl .sy cat mypic.ps \!PE \!. In devps (from Pipeline Associates), you simply need to add a second exclamation point for a line of included code: \!! PostScript code here so that devps will know to pass the line directly to the printer. I find the .sy request particularly useful, since you can use sed to edit your PostScript file to insert the extra exclamation point: .sy sed -e 's/^/!/' file.ps Devps includes a number of troff macros for including PostScript special effects, as well as for taking care of figure spacing problems. With all of this, you can have problems if you include PostScript code that isn't well behaved. At a minimum, your code should save and restore the context. You may also need to temporarily redefine the showpage operator. We hope to have a Nutshell Handbook out on this topic sometime later this year. Till then, I hope this helps. -- Tim O'Reilly (617) 527-4210 O'Reilly & Associates, Inc., Publishers of Nutshell Handbooks 981 Chestnut Street, Newton, MA 02164 UUCP: uunet!ora!tim ARPA: tim@ora.uu.net
jay@unm-la.UUCP (Jay Plett) (02/06/88)
In article <901@ora.UUCP>, tim@ora.UUCP (Tim O'Reilly) writes: > In addition, Berkeley ditroff includes a special escape sequence, \X, > which allows you to include in-line code: > > \X'PostScript code' This isn't a berkeleyism, it's from AT&T. If you have DWB or even a fairly recent ditroff, chances are good you have \X. It isn't in the manuals, but it is in the code. -- Jay Plett UUCP: {cmcl2,ihnp4}!lanl!unm-la!jay {ucbvax,gatech}!unmvax!unm-la!jay ARPA: jxyp@lanl.gov
ssl@ticnj.UUCP (Steven S. Levinn) (02/09/88)
In article <901@ora.UUCP>, tim@ora.UUCP writes: > In article <4594@venera.isi.edu>, cracraft@venera.isi.edu (Stuart Cracraft) writes: > > Is there a way to embed post-script images in troff text? > > For example, the PostScript language could be used to produce > > a fancy table or image, and this PostScript language and/or > > image could somehow be inserted in the middle of a troff > > document. > > > It depends on the postprocessor you're using. To include > PostScript code in troff is simply a matter of using any one > of a number of troff mechanisms. For example, there's so > called "transparent output": > > \! PostScript code here > Much more info about troff macros was included in the article My question to those of you out there that use psfig and the psfig macros with troff: How do you include uploaded pictures from the mac in your troff document? I upload (clover-F output) and try to include the files using psfig macros. I don't understand the mac Postscript (output from macdraw or a screen sweep from macterm for example) enough to include the proper %%BoundingBox info. I'm not sure it would work even if I did. Any pictures I include seems to eliminate (or at least not print) any output before the last picture. If any of you have sucessfully included pictures from the mac in your troff docs please give me a call or send mail. I will summarize any info I get. For handwritten postscript the psfig macros work just great. They scale, allocate the correct amount of space and correctly work like any troff pre-processor. Thanks, Steve Levinn 201-747-4700 ihnp4!attunix!ticnj!ssl
axel@coma.UUCP (Axel Mahler) (02/11/88)
In article <901@ora.UUCP> tim@ora.UUCP (Tim O'Reilly) writes: +>In article <4594@venera.isi.edu>, cracraft@venera.isi.edu (Stuart Cracraft) writes: +>> Is there a way to embed post-script images in troff text? +>> For example, the PostScript language could be used to produce +>> a fancy table or image, and this PostScript language and/or +>> image could somehow be inserted in the middle of a troff +>> document. +>> +> ( descriptions how to do it ) +>Of course, when you do any of these things, you must make allowances, +>in troff, for spacing and so forth, so troff and the output device +>don't get out of sync! For example, if you are going to +>interpolate the contents of a PostScript file containing a +>figure, you must tell troff to space down, or else it will +>resume printing at the original position, right on top of +>the figure. +> ( more descriptions of possible interferences of generated with included PostScript ) All the problems you have mentioned here are tackled by the 'Encapsulated PostScript File format' (EPSF), defined by Adobe. EPSF gives rules for writing/generating 'well-behaved' PostScript programs. EPSF files also contain BoundingBox defintions, giving the angle-points for the smallest rectangle containing the entire figure. This format gives text processing programs (as TeX for instance, there are problems with troff) the opportunity to extract the necessary amount of space from the picture itself. Even better: as PostScript allows arbitrary scaling of figures, one is able to define the size of a figure box from within the text processor and later fit (i.e. scale) the figure into this box. So, the optical appearance of the printed document isn't dominated by the picture's natural dimensions but the picture fits conveniently into the layout concept of the document. The latter mechanism gives even troff a chance. All you need is a program to be called (e.g. by means of .sy) from within the text processor with parameters specifying the dimensions a picture shall have in the output, and the name of the file containing the PostScript description. This program would scan the PostScript file for the BoundingBox information, and compute necessary scalings and translations to fit the picture into the given area on the output page. Taking this approach, linking a picture into troff could look like: .sy fitps -llx=1.4i -lly=3.2i -urx=6.0i -ury=8.4i mypict.eps +>I find the .sy request particularly useful, since you can I do too, for obvious reasons. Which version of ditroff introduces the various requests (.cf, .sy in particular) you mentioned ? We have troff of DWB 1.0 which lacks the .sy feature. To make a mechanism work that is similar to the one described above, we had to hack our ditroff->PostScript driver. cheers, Axel. -- Axel Mahler, Tech.Univ. Berlin UUCP: axel@coma.uucp (unido!coma!axel) BITNET: axel@db0tui62.bitnet
jonab@CAM.UNISYS.COM (Jonathan P. Biggar) (02/17/88)
In article <262@ticnj.UUCP> ssl@ticnj.UUCP (Steven S. Levinn) writes: >How do you include uploaded pictures from the mac in your troff document? >I upload (clover-F output) and try to include the files using psfig macros. >I don't understand the mac Postscript (output from macdraw or a screen sweep >from macterm for example) enough to include the proper %%BoundingBox info. >I'm not sure it would work even if I did. >Any pictures I include seems to eliminate >(or at least not print) any output before the last picture. >If any of you have sucessfully included pictures from the mac in your >troff docs please give me a call or send mail. I will summarize >any info I get. > >For handwritten postscript the psfig macros work just great. They >scale, allocate the correct amount of space and correctly >work like any troff pre-processor. 1) Get a copy of the Mac LaserPrep uploaded to your unix system using clover-K instead of clover-F. 2) Edit the LaserPrep file and make two changes: a) strip out the definitions of stretch and smooth that are defined using eexec. I have not figured out how to modify the LaserPrep so that these can remain. If your postscript printer already has the LaserPrep downloaded, then you will have no problem. Otherwise, you might have to turn off smoothing. b) find the definitions of "bigs" and "smalls". They will be defined as an array of 9 entries, some of which are the word "lnop". Change them so that all 9 entries are just "lnop". This removes the code in the LaserPrep that fiddles with the page size definitions and the default matrix. Also strip out the postscript for the figure you were printing when you used clover-K. 3) Include the LaserPrep file in your document via: .F+ file LaserPrep global; .F- before the first figure. Jon Biggar jonab@cam.unisys.com