Re: [R] Getting eps into Word documents.

From: Marc Schwartz (via MN) <>
Date: Tue 04 Oct 2005 - 07:44:05 EST

On Mon, 2005-10-03 at 22:00 +0100, Ted Harding wrote:
> Rolf (& Marc)
> On 03-Oct-05 Marc Schwartz (via MN) wrote:
> > On Mon, 2005-10-03 at 16:31 -0300, Rolf Turner wrote:
> >> A student in one of my courses has asked me about getting R graphics
> >> output (under Linux) into a Word document. I.e. she wants to do her
> >> R thing under Linux, but then do her word processing using Word.
> >>
> >> Scanning around the r-help archives I encountered an inquiry about
> >> this topic --- eps into Word documents --- from Paul Johnson but
> >> found no replies to it. I tried contacting him but the email address
> >> in the archives appeared not to be valid. Does anyone know a
> >> satisfactory solution to the problem of including a graphic which
> >> exists in the form of a *.eps (encapsulated postscript) file into a
> >> Word document. If so, would you be willing to share it with me and
> >> my student?
> >>
> >> If so, please be gentle in your explanation. I am not myself (repeat
> >> ***NOT***) a user of Word!
> >
> > Hehe... :-)
> >
> > Rolf, just use the guidance provided in ?postscript. In the details
> > section it indicates:
> >
> > The postscript produced by R is EPS (_Encapsulated PostScript_)
> > compatible, and can be included into other documents, e.g., into
> > LaTeX, using '\includegraphics{<filename>}'. For use in this way
> > you will probably want to set 'horizontal = FALSE, onefile =
> > FALSE, paper = "special"'.
> >
> > So use something like the following:
> >
> >
> > postscript("RPlot.eps", height = 4, width = 4,
> > horizontal = FALSE, onefile = FALSE,
> > paper = "special")
> >
> > plot(1:5)
> >
> >
> >
> >
> > You can then import the .eps file into Word or most other such
> > applications that can import encapsulated postscript files.
> >
> > The recent versions of Word will also automatically generate a
> > bitmapped preview of the plot upon import. BTW, 2.0,
> > which is in late beta testing now, also generates EPS preview
> > images upon import.
> >
> > The key to doing this successfully is using the arguments to
> > postscript() as defined above. I have never had a problem with this.
> >
> > More information is available from MS here:
> >
> >
> >
> > HTH,
> >
> > Marc Schwartz
> This suggestion could be problematic in that


> a) According to the MS web site above, it applies to recent Word
> (Office 2002/2003) or possibly earlier "depending on installed
> graphics filters".

The Word EPS filter has been around for some time. I recall using it years ago. Note that it is listed on that site in both categories of filters for some reason. In the older versions of Word, there was no preview image generated, hence you ended up with a box/frame place holder of sorts, unless you added a preview image before importing.

That being said, one does need to install the import filters from the Office CD, which may not be part of the default settings on all prior versions. It may require going back into the Office set up program to install them.

> b) It won't work anyway if printed to a non-PostScript printer.

True, which is the case irrespective of Word/Windows. If you don't have a PS printer locally or accessible via network, you can always install a PS printer driver and print to a file, which can then be printed by a third party if required.

If one has ps2pdf/Ghostscript available, you can also convert the PS file to PDF and then print it via Acrobat or other PDF viewers.

> If either of these applies to Rolf's student, she could have problems.
> [Just to add my own "disclaimer": the only version of Word I'm in
> any position to ever touch, and then only if driven to, belongs
> to Office 98; and I'm sure that this doesn't know a thing about
> PostScript!]
> Another option to consider, since she's doing her R work on Linux,
> is that recent versions of the ImageMagick program 'convert' have
> the capability to convert EPS into WMF (Windows Metafile; use
> file extension ".wmf" for 'convert') or EMF (Enhanced Metafile);
> use file extension ".emf". The gubbins is built in to a file
> "" in the lib/ImageMagick tree.
> Likewise, the program 'pstoedit' can do it (to ".wmf" or ".emf"),
> using library /usr/local/lib/pstoedit/ (on my machine).
> Most Linux distributions these days come with ImageMagick and
> pstoedit. If not already installed in the machine she's using it
> should be straightforward to get this dome.
> Hoping this helps,
> Ted.

Ted, the critical issue with doing the WMF/EMF conversion on Linux is that the libEMF stuff generates lousy quality (and visually bitmapped) output. I have tried it in the past and gave up, staying with EPS/PDF formats for vector graphics. If one wants to convert the EPS file to WMF/EMF, it is best done on Windows using native Windows drivers, rather than on Linux.

When SVG graphics go mainstream and cross-platform, that should help significantly with this whole issue.

HTH, Marc mailing list PLEASE do read the posting guide! Received on Tue Oct 04 07:47:48 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:40:35 EST