24

I heard that we can view pdf files in emacs. Is it done by converting pdf files to plain texts first?

Can we view pdf files at its fullness in emacs?

can we edit pdf files in emacs?

Thanks.

Dan
  • 32,584
  • 6
  • 98
  • 168
Tim
  • 4,987
  • 7
  • 31
  • 60

2 Answers2

23

You can give a try to pdf-tools, which provides most of the requested functionality

alper
  • 1,238
  • 11
  • 30
csantosb
  • 1,045
  • 6
  • 15
19

Since Emacs 23, you can view PDF files as images just by opening them like normal files as long as you have Emacs running in X rather than a terminal. You can also see and edit the PDF directly, which will display the contents of the binary file as text (with lots of unprintable characters!). You can edit this text directly, but unless you can encode and decode PDFs in your head, it won't be very useful.

You can switch between the two views with C-c C-c.

enter image description here

The same file both as an image preview and as text. I should learn to label my axes ;).

Text mode isn't very useful for PDFs, but it also works on some human-readable formats like .ps and .svg, which is useful for editing those files in place.

Tikhon Jelvis
  • 6,152
  • 2
  • 27
  • 40
  • 1
    (1) Can Emacs show the bookmarks of a pdf file, as in evince? I don't find it can. (2) Do you have two buffers for the two windows? I can always show either the code or the pdf in both windows. – Tim Sep 23 '14 at 22:24
  • @Tim: I don't know about bookmarks. I have the same file in both buffers, but that seems hard to reproduce; it just came up when I split the screen (ie `C-x 3`). If I use `C-c C-c`, the two windows become the same and I can't go back to seeing both at the same time. – Tikhon Jelvis Sep 23 '14 at 22:25
  • we can edit pdf files only by editing their code directly? Can we edit pdf files in WYSIWYG way in emacs? – Tim Sep 23 '14 at 22:26
  • @Tim: Not as far as I know. Given how terrible the PDF format is, don't expect it any time soon. But it's very useful if you're generating a PDF from LaTeX or something, as well as for working with the other formats I mentioned. – Tikhon Jelvis Sep 23 '14 at 22:44
  • 1
    This only works since emacs 23. – rlazo Sep 24 '14 at 11:51
  • @rlazo: Oh, thanks! I pretty much started using Emacs around 23, so I'm not too familiar with what came before. – Tikhon Jelvis Sep 24 '14 at 17:51
  • Does this work on `cygwin`? For me pdf open in `text-mode` – Miserable Variable May 22 '17 at 00:34