The gtk-vector-screenshot program can be used to take vector screenshots of Gtk-3 applications. It seems to work by asking the application to redraw itself onto an SVG canvas.

Emacs on GNU/Linux can be built with Gtk+, but trying to use the aforementioned application on an Emacs window results in a screenshot that only contains GUI elements such as the menu bar; buffers are not rendered (I tried with and without Cairo). This is not too surprising, given that Emacs' buffer rendering happens at a pretty low level.

Still, is there a way to take scalable vector screenshots of Emacs?

2 Answers 2


It's possible in Cairo builds, which are now the default on GNU/Linux!

(x-export-frames FRAMES TYPE)

Return image data of FRAMES in TYPE format.
FRAMES should be nil (the selected frame), a frame, or a list of
frames (each of which corresponds to one page).  Each frame should be
visible.  Optional arg TYPE should be either `pdf' (default), `png',
`postscript', or `svg'.  Supported types are determined by the
compile-time configuration of cairo.
  • how do you find out if your emacs is compiled with Cairo?
    – Fergie
    Commented Dec 9, 2020 at 6:47
  • You can try using that function ;)
    – Clément
    Commented Dec 9, 2020 at 22:27
  • Sadly not there. I am running a Mac- after some Googling it seems that Cairo is not available om OSX?
    – Fergie
    Commented Dec 10, 2020 at 6:49
  • Have created a related question to cover my usecase -> emacs.stackexchange.com/questions/62181/…
    – Fergie
    Commented Dec 10, 2020 at 6:51

According to the documentation Gtk+ widgets in Emacs are:

  • menus,
  • dialogs,
  • tool bars and
  • scroll bars

Buffers are rendered by Emacs itself. Neither the buffer nor the lines in a buffer are Gtk+ widgets. This means they do not know anything about the export functionality of Gtk+ widgets.

The best thing you can do is to use htmlfontify-buffer in order to embed the generated HTML into your SVG containing the widgets. But this will require some additional work to merge the HTML and SVG. But be aware that htmlfontify-buffer has also some limitations and does not work with every buffer.

  • I'm not sure this answers the question. I did mention take-vector-screenshot as an example, but I also mentioned that it wasn't surprising that it didn't work. htmlfontify-buffer has too many limitations to really qualify (it won't render overlays, display-string, line wraps, font fallback, etc.)
    – Clément
    Commented Feb 16, 2016 at 14:41
  • 1
    @Clément The short answer is: no way.
    – ceving
    Commented Feb 16, 2016 at 14:42
  • Is this personal opinion, or do you have evidence to back that claim? Given the number of rendering backends (Cairo, directly through X, Gtk, etc.) that Emacs has, one could imagine that a slight tweak to one of them might be enough.
    – Clément
    Commented Feb 16, 2016 at 15:18
  • 2
    @Clément Gtk+ can render to SVG, because Gtk+ uses Cairo, which has a backend for SVG. Emacs does not use Cairo for the buffer rendering. But there is a experimental branch for Cairo. Maybe in the near future it might be possible.
    – ceving
    Commented Feb 17, 2016 at 8:46
  • Cairo builds are now the default.
    – Clément
    Commented Jul 4, 2020 at 5:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.