emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Org-mode to MS-Word/OOo with vector graphics
@ 2010-09-02 14:45 Tom Short
  2010-09-02 19:21 ` David Maus
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Short @ 2010-09-02 14:45 UTC (permalink / raw)
  To: emacs-orgmode

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]]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-09-02 20:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-02 14:45 Org-mode to MS-Word/OOo with vector graphics Tom Short
2010-09-02 19:21 ` David Maus
2010-09-02 19:55   ` Short, Tom

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).