Skip to content

Getting eps into Word documents.

12 messages · Tom, Rolf Turner, (Ted Harding) +7 more

Tom
#
On Mon, 2005-03-10 at 16:31 -0300, Rolf Turner wrote:
R can also create more generic image formats such as png, i just use
these when I'm forced to insert graphics for presentations
?png
#
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!

Thanks.

			cheers,

				Rolf Turner
				rolf at math.unb.ca
#
On Mon, 2005-10-03 at 16:31 -0300, Rolf Turner wrote:
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)

dev.off()


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, OO.org 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:

http://support.microsoft.com/?kbid=290362

HTH,

Marc Schwartz
#
Rolf (& Marc)
On 03-Oct-05 Marc Schwartz (via MN) wrote:
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".

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

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
"wmf.so" in the lib/ImageMagick tree.

Likewise, the program 'pstoedit' can do it (to ".wmf" or ".emf"),
using library /usr/local/lib/pstoedit/libp2edrvwmf.so (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.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 03-Oct-05                                       Time: 22:00:11
------------------------------ XFMail ------------------------------
#
on 10/3/2005 3:31 PM Rolf Turner said the following:
Recent versions of Word import EPS quite well.  I just tried it with 
Word 2003 (also known as Word 11), and the figure was imported 
properly.  Word added a preview all by itself.

To do this, I opened an Explorer (directory) window on the directory 
with the files, then dragged the EPS file to Word.  I am certain it can 
also be done through the menu system.

I then converted an EPS file's line endings to *ix format and repeated 
the above.  It still worked fine.
#
On Mon, 2005-10-03 at 22:00 +0100, Ted Harding wrote:
Ted,
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.
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.
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
#
as far as I know (and I am not a specialist), there is no way of 
importing EPS in word, nor in openoffice, if you want to be able to 
"see" the graphics in the word processor and not only a placeholder. So 
either
a) use formats such as bmp, png,
or
b) under windows: convert eps to e.g. wmf using a tool, such as corel 
draw, or import the eps into powerpoint, then save it as wmf
c) try to import the eps in inkscape (I think this opensource tool is 
available also for windows), but I have never tried this

.. I have to admit, that under linux I have found no way so far, to 
import an eps graphics into a word document (neither ooo writer, nor 
msword, running with wine).

Christoph
tom wright wrote:
#
<Ted.Harding <at> nessie.mcc.ac.uk> writes:
I am using pstoedit for ps/emf for all my work, and it works nicely. There is 
one catch, though: If you plot any data that should be clipped (e.g. when 
setting xlim/ylim), pictures are nice in ps, but the clipped points turn up 
again in emf. This can make for nasty effect in panel plots where suddenly data 
turn up again in the wrong panel.

According to the author of pstoedit, this is a feature (i.e. bug) in emf that 
cannot easily be corrected. Only workaround: clip data sets manually.

Dieter
#
On Mon, 3 Oct 2005, Marc Schwartz (via MN) wrote:

            
We've been using this route for more than a decade (on both Windows and 
Classic MacOS).  You can use GSView, Photoshop, ... to add a preview if 
you desire.
Even then, there are problems.  Word has several known problems with the 
way it handles imported wmf/emf files (including those produced by R's 
win.metafile).  These include text losing orientation, lines changing 
width and ugly behaviour of dashed lines.  One or another of these seem to 
hit most of our people's attempts to go this route.
#
On Tue, 4 Oct 2005, Christoph Lehmann wrote:
<SNIP>
|.. I have to admit, that under linux I have found no way so far, to
|import an eps graphics into a word document (neither ooo writer, nor
|msword, running with wine).
</SNIP>

Hi,

There are lots of tools under linux, that can do the job of performing the
.eps conversion to several formats including ps, png, jpg, bmp, pdf, tiff,
targa, gif etc. For Eg, gimp, convert (from ImageMagick) and others.

Gimp is almost, but not quite entirely unlike Adobe Photoshop :) whereas
convert is command-line based, yet a powerful image interconversion tool.

The easiest way I feel, would be to convert .eps to one of the several
other compatible formats and then use them in M$-Word or OpenOffice.

HTH,

Senthil
#
--------------snip--------------
-------------snip----------------
----------snip-----------
Well, as a lowly Windows and Office user, I most often right click on R
grahics, cut to clipboard, and paste into Word.   So one possiblility is for
the student to install R on her own machine (Windows or Mac?).

But I just tried Marc's suggestion, and it looks VERY VIABLE to me.  I
generated the graph from his code snippet and used "Insert picture from
file" in Word 2003 to place the graphic in a Word document.  I then tried
printing on both an HP 4100 TN laserjet and an HP 960c deskjet.  The image
printed perfectly on both printers with crisp lines and text that apprear to
be vector-based not degraded bitmapped representations.  Certainly worth the
student trying.

HTH,
Rob Baer
#
On Tue, 2005-10-04 at 08:38 -0500, Robert Baer wrote:
Glad to hear that worked for you.

I do think that the majority of problems with importing EPS files from R
into other applications (Word, Powerpoint, Writer, Impress, etc.) are
due to not properly configuring the postscript() arguments that are on
the help page. 

I should also note that beyond plots, I use this same approach for
putting LaTeX tables into these documents as well. There are times where
I need create one or more nicely formatted tables for inclusion in
another document, to then be used by someone else.

I generate the LaTeX preamble, document and table code using R, then
run:

  latex FileName.tex
  dvips -E FileName -o FileName.ps

where the '-E' option to dvips attempts to create an EPS output file
with a tight bounding box. The result is a single EPS file with the
table (much like the plot example) ready for import.

I had been using 'epstool' to create the image preview, but now that
OO.org 2.0 has included this automatically upon import (as do the latest
versions of Word), this step is no longer required.

In this way, I can use R to create reproducible and publication ready
tables for use by others in their documents, in situations where they
are not (or cannot) use LaTeX for the entire document.

HTH,

Marc