How to take screen shot for business people efficiently in Emacs

  |   Source

CREATED: <2013-10-23 Wed>

UPDATED: <2015-08-11 Tue>

1 Tools

Name Description Minimum version
Org-mode create org-file which could be converted to odt file 7.8
scrot command line tool to take screen shot any version
Libreoffice convert odt to Microsoft Word any version
xsel X clipboard tool any version

2 Work flow

2.1 Use scrot to screenshot and put its path into clipboard

scrot '%H%M%S-%d_$wx$h.png' -e 'mkdir -p ~/screenshot;mv $f ~/screenshot/;echo ~/screenshot/$f|tr -d \"\\n\"|xsel -ib;'

2.2 Create org file and insert path of screen shot

Actually I use below elisp command to do the insertion for me.

(defun insert-file-link-from-clipboard ()
  "Make sure the full path of file exist in clipboard. This command will convert
The full path into relative path and insert it as a local file link in org-mode"
  (let (str)
        ((eq system-type 'cygwin) "getclip")
        ((eq system-type 'darwin) "pbpaste")
        (t "xsel -ob"))
      (setq str (buffer-string)))

    ;; convert to relative path (relative to current buffer) if possible
    (let ((m (string-match (file-name-directory (buffer-file-name)) str) ))
      (when m
        (if (= 0 m )
            (setq str (substring str (length (file-name-directory (buffer-file-name)))))
        (insert (format "[[file:%s]]" str)))

2.3 Convert org file into Microsoft Word format

I'm sure this method works even on Windows. But I don't have Windows PC to validate my belief. Libreoffice is required.

Run the command "M-x org-export-as-odt".

Word document is automatically created if you insert below code into your ~/.emacs:

;; This setup is tested on Emacs 24.3 & Emacs 24.4 on Linux/OSX
;; org v7 bundled with Emacs 24.3
(setq org-export-odt-preferred-output-format "doc")
;; org v8 bundled with Emacs 24.4
(setq org-odt-preferred-output-format "doc")
;; BTW, you can assign "pdf" in above variables if you prefer PDF format

;; Only OSX need below setup
(defun my-setup-odt-org-convert-process ()
  (let ((cmd "/Applications/"))
    (when (and (eq system-type 'darwin) (file-exists-p cmd))
      ;; org v7
      (setq org-export-odt-convert-processes '(("LibreOffice" "/Applications/ --headless --convert-to %f%x --outdir %d %i")))
      ;; org v8
      (setq org-odt-convert-processes '(("LibreOffice" "/Applications/ --headless --convert-to %f%x --outdir %d %i"))))

Emacs will find the binary "soffice" from libreoffice to do the conversion.

2.4 Tips

If you need page break in exported document, insert below snippet into the org file:

#+ODT: <text:p text:style-name="PageBreak"/>
Comments powered by Disqus