emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Org-mode to MS-Word/OOo with vector graphics


From: Tom Short
Subject: [Orgmode] Org-mode to MS-Word/OOo with vector graphics
Date: Thu, 2 Sep 2010 14:45:22 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

I've tried several approaches to converting org-mode files to MS-Word
or OpenOffice.org that retains vector graphics, especially
encapsulated postscript files. Some options I've tried include docbook
export with docbook2odf (doesn't work with docbook v5) and latex
export with tex4ht (converts graphics to png). 

HTML export with orgmode's html exporter worked the best for me. The
key is to have orgmode's exporter inline EPS (or other vector
graphics) rather than inserting a link. Both MS-Word and
OpenOffice.org can import html in this fashion and pull in the vector
graphics.

Although this isn't org-babel specific, it's convenient to use with
org-babel since there are so many ways to generate graphic files. See
below for an example that uses R to create EPS and windows metafiles
(windows only).

I'm curious to hear if it works for anyone else.

- Tom

----------------------------
#+TITLE: Vector graphic tests
#+BABEL: :session *R* :results output :exports both

This is a test of HTML export with vector graphics that can be read
into MS-Word and OpenOffice.org. We need to tell orgmode's export to
inline EPS and WMF files. Those image files won't be displayed in a
browser, but they will be imported into MS-Word or OpenOffice.org
Writer.

We also need to strip off the XML header line as discussed here

[[http://thread.gmane.org/gmane.emacs.orgmode/26236/focus=26238]]

That's taken care of by the "(setq org-export-html-xml-declaration"
below.

Note that all of this is based on with Windows XP and R 2.11.1.

#+begin_src emacs-lisp
(setq org-export-html-inline-image-extensions
  '("png" "jpeg" "jpg" "gif" "ps" "eps" "wmf" "emf"))

(setq org-export-html-xml-declaration
  '(("html" . "")
    ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\";
?>")))
#+end_src


* EPS

For EPS import into MS-Word 2003, it works fine with the extension
".eps" but not always with the extension ".ps", so we can't use
org-babel-R's built-in graphics support which defaults to the ".ps"
extension. OpenOffice.org 3.2 seems to work fine with either
extension.

#+begin_src R  :results value file
  setEPS() # set up the postscript driver for EPS output
  fname = "cos.eps"
  postscript(fname)
  plot(cos)
  dev.off()
  fname
#+end_src

#+results:
[[file:cos.eps]]


* WMF

The WMF works in MS-Office and in OpenOffice.org. WMF files don't look as
nice as EPS files for printed output, but they sometimes work okay
in powerpoints.

#+begin_src R  :results value file
  fname = "sin.wmf"
  win.metafile(fname, width = 5, height = 5)
  plot(sin)
  dev.off()
  fname
#+end_src

#+results:
[[file:sin.wmf]]






reply via email to

[Prev in Thread] Current Thread [Next in Thread]