home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2588 < prev    next >
Internet Message Format  |  1991-01-22  |  3KB

  1. From: mh@roger.imsd.contel.com (Mike Hoegeman)
  2. Newsgroups: alt.sources,comp.windows.news,comp.editors,comp.windows.open-look
  3. Subject: elvis (vi clone) .doc to postscript filter
  4. Message-ID: <1991Jan18.232508.9465@wlbr.imsd.contel.com>
  5. Date: 18 Jan 91 23:25:08 GMT
  6.  
  7. this script "ftops", converts elvis .doc files to
  8. postscript. Here is an example
  9.  
  10.     refont -f *.doc | ftops  > elvisDoc.ps
  11.  
  12. refont comes with the elvis package. ftops conforms enough to
  13. structured postscript to make it usable with the X11/NeWS pageview
  14. postscript previewer. just snip at cut here line and chmod +x the thing
  15.  
  16. --------------------------------CUT HERE------------------------------
  17. #!/bin/sh 
  18. if [ X$1 != X ]; then
  19.     2>&1 cat <<\EOF
  20.  
  21.     ftops is a simple filter, it reads from stdin and writes to stdout 
  22.     
  23.     it is used for converting files with \f<fontstyle> type font change
  24.     escapes to postscript. it is a quick hack to convert elvis .doc
  25.     files to postscript
  26.  
  27.     e.g. usage;
  28.  
  29.     refont -f *.doc | ftops > elvisDoc.ps
  30.  
  31. EOF
  32.     exit 1
  33. fi
  34.  
  35.  
  36. translate () {
  37. sed \
  38.     -e 's,(,\\\(,g' \
  39.     -e 's,),\\\),g' \
  40.     -e 's,\\fB,) p B setfont (,g' \
  41.     -e 's,\\fI,) p I setfont (,g' \
  42.     -e 's,\\fR,) p R setfont (,g' \
  43.     -e 's,\\fU,) p U setfont (,g' \
  44.     -e 's,^,(,' \
  45.     -e 's,$,) ShoW_LinE,'
  46.  
  47. cat <<\PS_PROLOG
  48. %!
  49. %%Pages: (atend)
  50. %%DocumentFonts Courier Courier-Oblique Courier-BoldOblique 
  51. %%Title: ftops shell script output
  52. %%Creator: ftops
  53. %%EndComments
  54.  
  55. /inch { 72 mul } bind def
  56. /getfont { exch findfont exch scalefont } bind def
  57.  
  58. /SheetWidth 8.5 inch def
  59. /SheetHeight 11 inch def
  60. /LeftMargin 20 def
  61. /TopMargin 20 def
  62.  
  63. /bodyfontsize 12 def
  64. /bodyfont /Courier bodyfontsize getfont def
  65. /R bodyfont def
  66. /B /Courier-Bold bodyfontsize getfont def
  67. /I /Courier-Oblique bodyfontsize getfont def
  68. /U /Courier-BoldOblique bodyfontsize getfont def
  69.  
  70. /startpage
  71.     LeftMargin SheetHeight TopMargin sub moveto
  72.     R setfont
  73. } def
  74.  
  75. /endpage { showpage } def
  76.  
  77. % Function s: print a source line
  78. /s { 
  79.     gsave show grestore
  80.     currentpoint 
  81.     exch pop LeftMargin exch bodyfontsize sub 
  82.     moveto
  83. } def
  84.  
  85. /p { show } def 
  86. /ShoW_LinE { s } def
  87.  
  88. %%EndProlog
  89. PS_PROLOG
  90.  
  91. translate | awk 'BEGIN {
  92.     lines=0
  93.     maxlines=66
  94.     pages=1
  95. }
  96.     
  97. { #MAIN
  98.     if ($NF~/ShoW_LinE/) {
  99.         ++lines
  100.     }
  101.     if (lines==1) {
  102.         printf("%%%%Page: %d %d\n", pages, pages)
  103.         printf("startpage\n")
  104.     }
  105.     print
  106.     if (lines == maxlines) {
  107.         ++pages
  108.         printf("endpage\n")
  109.         lines=0
  110.     }
  111.  
  112. END {
  113.     printf("%%%%Trailer\n")
  114.     printf("%%%%Pages: %d\n", pages)
  115. } ' -
  116.  
  117. exit 0
  118.