Blog

Inserting vector graphics in Office documents

Sometimes I have the misfortune of having to write conference papers in Microsoft Word, instead of a more civilised environment like LaTeX. Usefully, Word will refuse to import any kind of vector image format except for their own proprietary and crippled format, WMF/EMF. So, when it comes to diagrams, most people tend to throw their arms up and resort to bitmap formats like PNG. This, however, makes for large file sizes, or fuzzy printouts, so it’s a sub-optimal solution.

Although there are plenty of hoops to jump through, it is however possible to generate reasonable EMF files from other vector formats, which Word will accept. There are a large number of pitfalls, not least because of poor standards-adhesion when it comes to rendering of said formats. Mac OS X’s PDF renderer is no exception, unfortunately, so frequently one will have to resort to various bizarre conversion pipelines to have something readable at the other end.

That said, sometimes it works.

So, this is the procedure I’ve been following, to generate EMF figures from artwork created in a variety of applications, including XFig (which I personally don’t use, but my PhD supervisor Carlo enjoys), Inkscape, and OmniGraffle.

  1. Install pstoedit, a tool which will take a variety of formats (PDF/EPS, for example) and convert them to another – EMF, in particular.
  2. Make sure the installed version supports EMF output – in Terminal, pstoedit -help | grep emf. If it doesn’t, you’ll need to find an other version elsewhere.
  3. If your diagram isn’t already in PDF or EPS format already, export it to one or the other.
  4. Try converting the PDF/EPS, as-is, as a first step. Some commands to try (open in Word/Powerpoint to see the result each time):
    • pstoedit -f emf diagram.pdf/eps output.emf
    • pstoedit -f emf -pta diagram.pdf/eps output.emf (Place letters individually, if text looks odd)
    • pstoedit -f "emf:-m" diagram.pdf/eps output.emf (Use Arial as font, if font looks wrong)
    • pstoedit -f emf -drawbb diagram.pdf/eps output.emf (Force drawing of bounding box – try this if you get cropping)
    • pstoedit -f emf -xscale 2 -yscale 2 diagram.pdf/eps output.emf (Scale up – use this if lines look blocky; experiment with larger values than 2)
    • pstoedit -f "emf:-m" -pta -drawbb diagram.pdf/eps output.emf (A combination of some of above)
  5. If your EMF version looks wrong, try exporting to EPS if you were using PDF, or PDF if you were using EPS – different renderers perform differently. Try above steps again on this new exported version.
  6. If this still doesn’t produce reasonable output, you’ll want to try another application that exports better-behaved PDF/EPS. You’ll need to import your diagram into such an application, make any cosmetic changes required to counteract any funny business as a result of the import, then export as PDF/EPS.
    • For a while, I was using Inkscape for this purpose, but I was still getting funny output sometimes.
    • I discovered a native OS X application called Intaglio, which seems to produce very good PDF output (not so much with EPS).
    • For either application, export your diagram in a format they can understand, to subsequently import.
      • Inkscape will basically only take SVG, from what I can remember. You can try converting the PDF/EPS to SVG using pstoedit again: pstoedit -f svg diagram.pdf/eps output.svg
      • Intaglio will happily take PDF and let you convert it to an editable format, which will work some of the time, with a reasonably well-behaved PDF. Drag the PDF onto the canvas, select it, then use Object, Convert, PDF for Editing.
    • Fix any visual problems caused by the import, using the application’s editing tools.
    • Export your diagram in PDF/EPS (try both, if necessary)
      • Intaglio seems to work best with PDF: Select the figure, then File, Save Selection As, select PDF and Crop to Content Size.
  7. Once you’ve exported PDF/EPS, repeat step 4 to try to generate reasonable output.

The whole process is undoubtedly an ordeal, and requires serious dedication, but it would appear to be required if you want to generate vector graphics in a Word document. Lets hope the geniuses at Microsoft remember to add a PDF/etc importer into their next Office.

. Bookmark the permalink. Both comments and trackbacks are currently closed.

8 Comments

  1. Reinier Post
    Posted October 1, 2007 at 12:35 pm | Permalink

    I was looking for this, and found this page, plus the easier way to do it:

    http://www.pstoedit.net/pstoedit/

    provides an installer for a Word plugin that lets you import PostScript pictures directly into Word.

  2. Michael
    Posted October 1, 2007 at 9:38 pm | Permalink

    Yes, that’s the pstoedit tool – and it works very well, but only if the original PDF/EPS is well formed. Unfortunately, many tools generate PDF that pstoedit struggles on (OS X’s PDF generator included) – hence my usage of Intaglio to generate better-formed PDF, when I then pass to pstoedit.

    The Word plugin simply runs the conversion to EMF step internally, and does the same thing as on the command line – one still needs PDF/EPS that it can parse correctly, alas.

  3. Posted October 18, 2010 at 8:22 am | Permalink

    Great howto, thanks. BTW, if you are struggling with ill-formed PS, pstops will often help to clean it up.

  4. Tim West
    Posted September 14, 2011 at 4:22 am | Permalink

    I have found that if you are having rendering issues due to MS not translating the vector well, enlarge your vector image artboard (sorry Illustrator Jargon) to 10 times what you need. Then save as emf. The result will generate much cleaner vectors at smaller sizes.

    Peace,

    TW

  5. Tim West
    Posted September 14, 2011 at 4:23 am | Permalink

    Oops, I forgot….

    Increase your art by ten times too!!

  6. Astralexis
    Posted January 1, 2012 at 10:35 am | Permalink

    It seems to me that Adobe Acrobat has added an Insert Object – Adobe PDF to my Word 2003. And it actually works, for the most part.

    Problem is with printing / saving that Word .doc to PDF format again. The vector graphic from the inserted PDF object is then transformed into low resolution pixel image.

    About the PSToEdit tool, I read there’s a plugin for Better EMF, is this worth buying?

  7. Paula
    Posted April 30, 2013 at 9:36 pm | Permalink

    So, I am running a very old version of .ai (illustrator 8.0, circa 1998 believe it or not) and MS Professional Plus 2010. Windows XP v5.1 Dell platform. The reasons why I am running such an old vsn of .ai are too long to get into here…. I am getting complaints about the same thing….poor JPGs in MS word , then output to PDF. The ending results are crap. Why can’t I use a vector format he says? Well, they still are not compatible.

    The solutions here are complicated (to me) and seem to be for a UNIX or mac platform.

    Can you suggest other ideas?

    THX,

    Paula

  8. Paula
    Posted April 30, 2013 at 10:02 pm | Permalink

    Actually, a trial we did seems to have worked…..

    .ai file => .eps, then inserted to MS Word. Looks lousy on screen, prints beautifully. Even as a PDF.