2018-06-06 03:30:47 +00:00
#+TITLE : PDF layer
2016-02-09 00:00:54 +00:00
2019-05-02 21:49:30 +00:00
#+TAGS : layer|reader
2016-03-04 05:51:34 +00:00
[[file:img/pdf.png ]]
2016-02-09 00:00:54 +00:00
2019-05-07 20:05:06 +00:00
* Table of Contents :TOC_5_gh:noexport:
2017-05-22 14:16:12 +00:00
- [[#description ][Description ]]
2017-10-04 08:13:01 +00:00
- [[#features ][Features: ]]
2017-05-22 14:16:12 +00:00
- [[#install ][Install ]]
- [[#prerequisites ][Prerequisites ]]
- [[#dotfile ][Dotfile ]]
- [[#usage ][Usage ]]
- [[#known-issues ][Known Issues ]]
- [[#key-bindings ][Key bindings ]]
- [[#pdf-view ][PDF View ]]
- [[#leader-keys ][Leader keys ]]
- [[#outline-buffer-mode ][Outline buffer mode ]]
- [[#annotation-list-mode ][Annotation list mode ]]
- [[#occur-mode ][Occur mode ]]
2016-02-09 00:00:54 +00:00
* Description
2018-06-06 03:30:47 +00:00
This layer enables support for PDF with the [[https://github.com/politza/pdf-tools ][pdf-tools ]] package.
2016-03-04 05:51:34 +00:00
According to the official repository:
2018-09-19 03:54:47 +00:00
#+BEGIN_QUOTE
2019-05-26 20:58:52 +00:00
"PDF Tools is, among other things, a replacement of DocView for PDF files. The
2018-09-19 03:54:47 +00:00
key difference is, that pages are not pre-rendered by e.g. ghostscript and
2019-05-26 20:58:52 +00:00
stored in the file-system, but rather created on-demand and stored in memory."
2018-09-19 03:54:47 +00:00
#+END_QUOTE
2016-02-09 00:00:54 +00:00
2017-10-04 08:13:01 +00:00
** Features:
- Searching and slicing with =occur= .
- Show document headings in outline buffer.
2016-02-09 00:00:54 +00:00
- Manipulate annotations.
2017-10-04 08:13:01 +00:00
- Fit PDF to screen.
2016-02-09 00:00:54 +00:00
* Install
** Prerequisites
2019-05-26 20:58:52 +00:00
Linux is the only operating system officially supported, but it's possible to
2019-10-13 05:27:17 +00:00
use =pdf-tools= on macOS as well, and possibly on other Unix flavors.
2016-02-09 00:00:54 +00:00
2019-05-26 20:58:52 +00:00
You'll need to install a few libraries. Check the [[https://github.com/politza/pdf-tools#server-prerequisites ][instructions ]] on
2016-02-09 00:00:54 +00:00
=pdf-tools= page. Note that compiling from source might not be necessary, as
the documentation states.
If you use a Debian based system such as Ubuntu, you can skip this step, as
=pdf-tools= installation asks whether you want it to try to download
2016-11-22 20:53:50 +00:00
automatically all dependencies using =apt-get= .
2016-02-09 00:00:54 +00:00
** Dotfile
After installing the dependencies, add this to your =~/.spacemacs= .
2018-09-19 03:54:47 +00:00
#+BEGIN_SRC emacs-lisp
2018-06-07 22:33:42 +00:00
(setq-default dotspacemacs-configuration-layers '(pdf))
2018-09-19 03:54:47 +00:00
#+END_SRC
2016-02-09 00:00:54 +00:00
After that, syncronize your configuration with ~SPC f e R~ . This will pop up a
window showing the compilation process.
2019-05-26 20:58:52 +00:00
If everything goes right, the compilation won't display any error and you will
2016-02-09 00:00:54 +00:00
be able to see /PDFView/ (instead of /DocView/ ) on the spaceline after opening a
pdf file.
2016-04-13 03:31:38 +00:00
If the compilation run successfully but you get
2016-11-22 20:53:50 +00:00
=Error (use-package): pdf-tools :config: No executable `epdfinfo' found= ,
2016-02-09 00:00:54 +00:00
try restarting Spacemacs ([[https://github.com/politza/pdf-tools/issues/31 ][issue ]]).
If the compilation does not run successfully, you should confirm whether all
2016-11-22 20:53:50 +00:00
dependencies are properly installed and run the command =pdf-tools-install= .
2016-02-09 00:00:54 +00:00
* Usage
2016-03-04 05:51:34 +00:00
Use ~SPC m .~ to activate the pdf-tools transient state.
2018-10-23 14:18:21 +00:00
The key bindings that the transient displays can be also accessed using ~SPC m~ . The
navigation key bindings can be used directly.
2016-02-09 00:00:54 +00:00
Try out opening the outline (~O~ ). The outline window shows the structure of the
pdf, displaying all headings.
You can set annotations by selecting regions and right clicking on the buffer.
2016-03-04 05:51:34 +00:00
Additionally, all annotation related functions can be accessed with ~SPC m a~ .
2016-02-09 00:00:54 +00:00
Searching with =occur= can be done by using =pdf-occur= (~SPC m s s~ ).
Tips:
2019-05-26 20:58:52 +00:00
- You'll probably want to use =pdf-view-set-slice-from-bounding-box= (bound to
2016-02-09 00:00:54 +00:00
~SPC m s b~ ) This command trims the blank parts of the
lateral margins, making the useful portion larger.
2021-02-28 08:00:52 +00:00
- The layer uses the package [[https://github.com/007kevin/pdf-view-restore ][pdf-view-restore ]] to store and restore last-visited
2021-03-13 23:57:56 +00:00
2021-02-28 08:00:52 +00:00
pages. By default the information is stored in the directory of the viewed
2021-03-13 23:57:56 +00:00
document (so it can get lost if you use e.g. [[https://calibre-ebook.com/ ][Calibre ]] / [[https:/ /github.com/chenyanming/calibredb.el][calibredb.el]] for your
2021-02-28 08:00:52 +00:00
document management). If you would like the information to get stored in a
different location then [[https://github.com/chenyanming/calibredb.el ][set the variable ]] =pdf-view-restore-filename= to the path
of the filename to use. Alternatively you can (additionally) use Emacs its
[[https://www.gnu.org/software/emacs/manual/html_node/emacs/Bookmarks.html ][bookmarks ]] system to store and revisit (=SPC f b= for both) any location
manually.
2016-04-13 03:31:38 +00:00
2016-03-04 05:51:34 +00:00
* Known Issues
2018-09-19 03:54:47 +00:00
Due to =image-mode= ’ s behaviour, the =pdf-tools= buffer might go back to the
2016-02-09 00:00:54 +00:00
first page after switching windows. If this happens, you can quickly go back to
the previous page in history with =pdf-history-backward= (~``~ in Evil state and
~B~ in Emacs state.)
* Key bindings
If you use Emacs editing style, check the key bindings at the [[https://github.com/politza/pdf-tools#some-keybindings ][pdf-tools page ]].
** PDF View
2018-12-05 03:03:03 +00:00
| *Key binding* | *Description* |
2016-02-09 00:00:54 +00:00
|----------------------+-------------------------------------------|
| *Navigation* | |
|----------------------+-------------------------------------------|
| ~M-SPC~ or ~s-M-SPC~ | pdf-tools transient state |
2016-07-24 19:22:52 +00:00
| ~0/$~ | Left/right full scroll |
2016-02-09 00:00:54 +00:00
| ~J~ | Move to next page |
| ~K~ | Move to previous page |
| ~u~ | Scroll page up |
| ~d~ | Scroll page down |
| ~gg~ | Go to the first page |
| ~G~ | Go to the last page |
| ~gt~ | Go to page |
| ~gl~ | Go to label (usually the line as printed) |
| ~C-u~ | Scroll up |
| ~C-d~ | Scroll down |
| ~``~ | Go to last page in the history |
| ~m~ | Set mark |
| ~'~ | Go to mark |
| ~y~ | Yank selected region |
2020-12-15 14:04:04 +00:00
| ~C-o~ or ~[~ | History back |
| ~C-i~ or ~]~ | History forward |
2016-02-09 00:00:54 +00:00
|----------------------+-------------------------------------------|
| *Search* | |
|----------------------+-------------------------------------------|
| ~/~ | Search forward |
| ~?~ | Search backward |
|----------------------+-------------------------------------------|
| *Actions* | |
|----------------------+-------------------------------------------|
| ~o~ | Follow link |
| ~O~ | Show outline |
| ~r~ | Refresh file |
|----------------------+-------------------------------------------|
2016-07-24 19:22:52 +00:00
| *Zoom* | |
|----------------------+-------------------------------------------|
| ~+/-~ | Zoom in/out |
| ~zr~ | Reset zoom |
|----------------------+-------------------------------------------|
2016-02-09 00:00:54 +00:00
/For evil users/ : Note that the search keys activate =isearch= , which works
differently from the default Evil search. To go to the next match, use ~C-s~ .
** Leader keys
2018-12-05 03:03:03 +00:00
| *Key binding* | *Description* |
2016-02-09 00:00:54 +00:00
|-----------------------+-------------------------------------------|
| *Slicing* | |
|-----------------------+-------------------------------------------|
2016-03-04 05:51:34 +00:00
| ~SPC m s m~ | Set slice using mouse |
| ~SPC m s b~ | Set slice from bounding box |
| ~SPC m s r~ | Reset slice |
2016-02-09 00:00:54 +00:00
|-----------------------+-------------------------------------------|
| *Annotations* | |
|-----------------------+-------------------------------------------|
2016-03-04 05:51:34 +00:00
| ~SPC m a D~ | Delete annotation (select it with mouse) |
| ~SPC m a a~ | List all attachments in a dired buffer |
| ~SPC m a h~ | Highlight visual selection |
| ~SPC m a l~ | List all annotations |
| ~SPC m a m~ | Add markup annotation to visual selection |
| ~SPC m a o~ | Strikeout visual selection |
| ~SPC m a s~ | Add squiggly to visual selection |
| ~SPC m a t~ | Add annotation text |
| ~SPC m a u~ | Underline to visual selection |
2016-02-09 00:00:54 +00:00
|-----------------------+-------------------------------------------|
| *Fit image to window* | |
|-----------------------+-------------------------------------------|
2016-03-04 05:51:34 +00:00
| ~SPC m f w~ | Fit width to window |
| ~SPC m f h~ | Fit height to window |
| ~SPC m f p~ | Fit page to window |
2016-02-09 00:00:54 +00:00
|-----------------------+-------------------------------------------|
| *Other* | |
|-----------------------+-------------------------------------------|
2016-03-04 05:51:34 +00:00
| ~SPC m n~ | Toggle night view mode |
| ~SPC m s~ | Run =pdf-occur= |
| ~SPC m p~ | Display print version |
2016-02-09 00:00:54 +00:00
** Outline buffer mode
2018-12-05 03:03:03 +00:00
| *Key binding* | *Description* |
2016-02-09 00:00:54 +00:00
|---------------+-------------------------------------------------------|
| ~S-tab~ | Expand all trees |
| ~RET~ | Follow link |
| ~M-RET~ | Follow link and close outline window |
| ~o~ | Go to pdf view window |
| ~``~ | Move to the heading correspondent to the current page |
| ~''~ | Move to the heading correspondent to the current page |
| ~f~ | Go to selected heading without leaving outline buffer |
| ~F~ | Enable follow mode |
| ~q~ | Quit |
| ~Q~ | Quit and kill outline buffer |
Note that you can use also typical Vim keys such as ~j~ and ~G~ .
** Annotation list mode
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2016-02-09 00:00:54 +00:00
|-------------+-------------------------------|
| ~d~ | Mark for deletion |
| ~x~ | Apply action for marked items |
| ~u~ | Unmark item |
| ~q~ | Quit |
** Occur mode
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2016-02-09 00:00:54 +00:00
|-------------+----------------|
| ~q~ | Quit |
| ~g~ | Refresh buffer |
| ~r~ | Refresh buffer |