Klimi's new dotfiles with stow.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

381 rinda
16 KiB

pirms 5 gadiem
  1. #+TITLE: PDF Tools README
  2. #+AUTHOR: Andreas Politz
  3. #+EMAIL: politza@fh-trier.de
  4. [[https://travis-ci.org/politza/pdf-tools.svg?branch%3Dmaster][https://travis-ci.org/politza/pdf-tools.svg?branch=master]]
  5. [[http://stable.melpa.org/#/pdf-tools][http://stable.melpa.org/packages/pdf-tools-badge.svg]]
  6. [[http://melpa.org/#/pdf-tools][http://melpa.org/packages/pdf-tools-badge.svg]]
  7. ** About this package
  8. PDF Tools is, among other things, a replacement of DocView for PDF
  9. files. The key difference is that pages are not pre-rendered by
  10. e.g. ghostscript and stored in the file-system, but rather created
  11. on-demand and stored in memory.
  12. This rendering is performed by a special library named, for
  13. whatever reason, poppler, running inside a server program. This
  14. program is called ~epdfinfo~ and its job is to successively
  15. read requests from Emacs and produce the proper results, i.e. the
  16. PNG image of a PDF page.
  17. Actually, displaying PDF files is just one part of PDF Tools.
  18. Since poppler can provide us with all kinds of information about a
  19. document and is also able to modify it, there is a lot more we can
  20. do with it. [[http://www.dailymotion.com/video/x2bc1is_pdf-tools-tourdeforce_tech?forcedQuality%3Dhd720][Watch]]
  21. Please read also about [[#known-problems][known problems.]]
  22. ** Features
  23. + View :: View PDF documents in a buffer with DocView-like
  24. bindings.
  25. + Isearch :: Interactively search PDF documents like any other
  26. buffer, either for a string or a PCRE.
  27. + Occur :: List lines matching a string or regexp in one or more
  28. PDF documents.
  29. + Follow ::
  30. Click on highlighted links, moving to some part of a different
  31. page, some external file, a website or any other URI. Links may
  32. also be followed by keyboard commands.
  33. + Annotations :: Display and list text and markup annotations (like
  34. underline), edit their contents and attributes
  35. (e.g. color), move them around, delete them or
  36. create new ones and then save the modifications
  37. back to the PDF file.
  38. + Attachments :: Save files attached to the PDF-file or list them
  39. in a dired buffer.
  40. + Outline :: Use imenu or a special buffer to examine and navigate
  41. the PDF's outline.
  42. + SyncTeX :: Jump from a position on a page directly to the TeX
  43. source and vice versa.
  44. + Virtual ::
  45. Use a collection of documents as if it were one, big single PDF.
  46. + Misc ::
  47. - Display PDF's metadata.
  48. - Mark a region and kill the text from the PDF.
  49. - Keep track of visited pages via a history.
  50. - Apply a color filter for reading in low light conditions.
  51. ** Installation
  52. The package may be installed via melpa and it will try to build the
  53. server part when it is activated the first time. Though the next
  54. section regarding build-prerequisites is still relevant, the rest
  55. of the installation instructions assume a build from within a git
  56. repository. (The melpa package has a different directory
  57. structure.)
  58. *** Server Prerequisites
  59. You'll need GNU Emacs \ge 24.3 and some form of a GNU/Linux OS.
  60. Other operating systems are currently not supported (patches
  61. welcome). The following instructions assume a Debian-based
  62. system. (The prerequisites may be installed automatically on this
  63. kind of systems, see [[#compilation][Compilation]] .)
  64. First make sure a suitable build-system is installed. We need at
  65. least a C/C++ compiler (both ~gcc~ and ~g++~), ~make~, ~automake~
  66. and ~autoconf~.
  67. Next we need to install a few libraries PDF Tools depends on, some
  68. of which are probably already on your system.
  69. #+begin_src sh
  70. $ sudo aptitude install libpng-dev zlib1g-dev
  71. $ sudo aptitude install libpoppler-glib-dev
  72. $ sudo aptitude install libpoppler-private-dev
  73. #+end_src
  74. On some older Ubuntu systems, the final command will possibly give
  75. an error. This should be no problem, since in some versions this
  76. package was contained in the main package ~libpoppler-dev~. Also
  77. note, that ~zlib1g-dev~ was for a long time called ~libz-dev~,
  78. which it still may be on your system.
  79. Debian wheezy comes with libpoppler version 0.18, which is pretty
  80. old. The minimally required version is 0.16, but some features of
  81. PDF Tools depend on a more recent version of this library. See
  82. the following table for what they are and what version they
  83. require.
  84. | You want to ... | Required version |
  85. |-------------------------------------------+------------------|
  86. | ... create and modify text annotations. | \ge 0.19.4 |
  87. | ... search case-sensitive. | \ge 0.22 |
  88. | ... create and modify markup annotations. | \ge 0.26 |
  89. |-------------------------------------------+------------------|
  90. In case you decide to install libpoppler from source, make sure
  91. to run its configure script with the ~--enable-xpdf-headers~
  92. option.
  93. Finally there is one feature (following links of a PDF document by
  94. plain keystrokes) which requires imagemagick's convert utility.
  95. This requirement is optional and you may install it like so:
  96. #+begin_src sh
  97. $ sudo aptitude install imagemagick
  98. #+end_src
  99. **** Compiling on OS X
  100. Although OS X is not officially supported, it has been reported
  101. to have been successfully compiled. You will need to install
  102. poppler which you can get with homebrew via
  103. #+BEGIN_SRC sh
  104. $ brew install poppler automake
  105. #+END_SRC
  106. You will also have to help ~pkg-config~ find some libraries by
  107. setting ~PKG_CONFIG_PATH~, e.g.
  108. #+BEGIN_SRC sh
  109. $ export PKG_CONFIG_PATH=/usr/local/Cellar/zlib/1.2.8/lib/pkgconfig:/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig
  110. #+END_SRC
  111. or likewise within Emacs using `setenv`.
  112. After that, compilation should proceed as normal.
  113. **** FreeBSD
  114. Although not officially supported, it has been reported that
  115. pdf-tools work well on FreeBSD. Instead of building pdf-tools, you
  116. can install one of the OS packages with, e.g.
  117. #+BEGIN_SRC sh
  118. $ pkg install pdf-tools-emacs26
  119. #+END_SRC
  120. To see the current list of pdf-tools packages for FreeBSD visit
  121. [[https://repology.org/metapackages/?search=pdf-tools&inrepo=freebsd][the Repology list]].
  122. To build pdf-tools from either melpa or directly from the source
  123. repository, install the dependencies with
  124. #+BEGIN_SRC sh
  125. $ pkg install autotools gmake poppler-glib
  126. #+END_SRC
  127. If you choose not to install from melpa, you must substitute
  128. ~gmake~ for ~make~ in the instructions below.
  129. **** Compiling on Centos
  130. It is possible to compile pdf-tools on Centos. Install poppler the dependencies with:
  131. #+BEGIN_SRC sh
  132. $ yum install poppler-devel poppler-glib-devel
  133. #+END_SRC
  134. **** Compiling on Fedora
  135. #+BEGIN_SRC sh
  136. $ sudo dnf install make automake autoconf gcc gcc-c++ ImageMagick libpng-devel zlib-devel poppler-glib-devel
  137. #+END_SRC
  138. **** Compiling on Alpine Linux
  139. #+BEGIN_SRC sh
  140. $ apk add build-base g++ gcc automake autoconf libpng-dev glib-dev poppler-dev
  141. #+END_SRC
  142. **** Compiling on Windows
  143. PDF Tools can be built and used on Windows using the MSYS2
  144. compiler. This will work with native (not cygwin) Windows builds of
  145. emacs. This includes the standard binaries provided by the GNU
  146. project, those available as MSYS2 packages and numerous third-party
  147. binaries. It has been tested with emacs 25.1. Instructions are
  148. provided under [[#compilation-and-installation-on-windows][Compilation and installation on Windows]], below.
  149. PDF Tools will successfully compile using Cygwin, but it will not be
  150. able to open PDFs properly due to the way binaries compiled with Cygwin
  151. handle file paths.
  152. *** Compilation
  153. :PROPERTIES:
  154. :CUSTOM_ID: compilation
  155. :END:
  156. Now it's time to compile the source.
  157. #+begin_src sh
  158. $ cd /path/to/pdf-tools
  159. $ make install-server-deps # optional
  160. $ make -s
  161. #+end_src
  162. The ~make install-server-deps~ command will try to install all
  163. necessary programs and libraries to build the package, though
  164. it'll only work, if ~sudo~ and ~apt-get~ are available.
  165. This should compile the source code and create a Emacs Lisp
  166. Package in the root directory of the project. The configure script
  167. also tells you at the very end, which features, depending on the
  168. libpoppler version, will be available. These commands should give
  169. no error, otherwise you are in trouble.
  170. **** Compilation and installation on Windows
  171. If using the GNU binaries for Windows, support for PNG and zlib
  172. must first be installed by copying the appropriate dlls into
  173. emacs' ~bin/~ directory. Most third-party binaries come with this
  174. already done.
  175. First, install [[http://www.msys2.org/][install MSYS2]] and update
  176. the package database and core packages using the instructions
  177. provided. Then, to compile PDF tools itself:
  178. 1. Open msys2 shell
  179. 2. Update and install dependencies, skipping any you already have
  180. #+BEGIN_SRC sh
  181. $ pacman -Syu
  182. $ pacman -S base-devel
  183. $ pacman -S mingw-w64-x86_64-toolchain
  184. $ pacman -S mingw-w64-x86_64-zlib
  185. $ pacman -S mingw-w64-x86_64-libpng
  186. $ pacman -S mingw-w64-x86_64-poppler
  187. $ pacman -S mingw-w64-x86_64-imagemagick
  188. #+END_SRC
  189. 3. Install PDF tools in Emacs, but do not try to compile the
  190. server. Instead, get a separate copy of the source somewhere
  191. else.
  192. #+BEGIN_SRC sh
  193. $ git clone https://github.com/politza/pdf-tools
  194. #+END_SRC
  195. 4. Open mingw64 shell (*Note:* You must use mingw64.exe and not msys2.exe)
  196. 5. Compile pdf-tools
  197. #+BEGIN_SRC sh
  198. $ cd /path/to/pdf-tools
  199. $ make -s
  200. #+END_SRC
  201. 6. This should produce a file ~server/epdfinfo.exe~. Copy this file
  202. into the ~pdf-tools/~ installation directory in your Emacs.
  203. 7. Start Emacs and activate the package.
  204. #+BEGIN_SRC
  205. M-x pdf-tools-install RET
  206. #+END_SRC
  207. 8. Test.
  208. #+BEGIN_SRC
  209. M-x pdf-info-check-epdfinfo RET
  210. #+END_SRC
  211. If this is successful, ~(pdf-tools-install)~ can be added to Emacs'
  212. config. Note that libraries from other GNU utilities, such as Git
  213. for Windows, may interfere with those needed by PDF Tools.
  214. ~pdf-info-check-epdinfo~ will succeed, but errors occur when trying
  215. to view a PDF file. This can be fixed by ensuring that the MSYS
  216. libraries are always preferred in emacs:
  217. #+BEGIN_SRC emacs-lisp
  218. (setenv "PATH" (concat "C:\\msys64\\mingw64\\bin;" (getenv "PATH")))
  219. #+END_SRC
  220. *** ELisp Prerequisites
  221. This package depends on the following Elisp packages, which should
  222. be installed before installing the Pdf Tools package.
  223. | Package | Required version |
  224. |-----------+----------------------------------|
  225. | [[https://elpa.gnu.org/packages/let-alist.html][let-alist]] | >= 1.0.4 (comes with Emacs 25.2) |
  226. | [[http://melpa.org/#/tablist][tablist]] | >= 0.70 |
  227. |-----------+----------------------------------|
  228. *** Installing
  229. If ~make~ produced the ELP file ~pdf-tools-${VERSION}.tar~ you are
  230. fine. This package contains all the necessary files for Emacs
  231. and may be installed by either using
  232. #+begin_src sh
  233. $ make install-package
  234. #+end_src
  235. or executing the Emacs command
  236. #+begin_src elisp
  237. M-x package-install-file RET pdf-tools-${VERSION}.tar RET
  238. #+end_src
  239. To complete the installation process, you need to activate the
  240. package by putting
  241. #+begin_src elisp
  242. (pdf-tools-install)
  243. #+end_src
  244. somewhere in your ~.emacs~. Alternatively, and if you care about
  245. start-up time, you may want to use
  246. #+begin_src elisp
  247. (pdf-loader-install)
  248. #+end_src
  249. instead. Next you probably want to take a look at the various
  250. features of what you've just installed. The following two commands
  251. might be of help for doing so.
  252. #+begin_src elisp
  253. M-x pdf-tools-help RET
  254. M-x pdf-tools-customize RET
  255. #+end_src
  256. *** Updating
  257. Some day you might want to update this package via ~git pull~ and
  258. then reinstall it. Sometimes this may fail, especially if
  259. Lisp-Macros are involved and the version hasn't changed. To avoid
  260. this kind of problems, you should delete the old package via
  261. ~list-packages~, restart Emacs and then reinstall the package.
  262. This also applies when updating via package and melpa.
  263. ** Known problems
  264. :PROPERTIES:
  265. :CUSTOM_ID: known-problems
  266. :END:
  267. *** linum-mode
  268. PDF Tools does not work well together with ~linum-mode~ and
  269. activating it in a ~pdf-view-mode~, e.g. via ~global-linum-mode~,
  270. might make Emacs choke.
  271. *** auto-revert
  272. Autorevert works by polling the file-system every
  273. ~auto-revert-interval~ seconds, optionally combined with some
  274. event-based reverting via [[https://www.gnu.org/software/emacs/manual/html_node/elisp/File-Notifications.html][file notification]]. But this currently
  275. does not work reliably, such that Emacs may revert the PDF-buffer
  276. while the corresponding file is still being written to (e.g. by
  277. LaTeX), leading to a potential error.
  278. With a recent [[https://www.gnu.org/software/auctex/][auctex]] installation, you might want to put the
  279. following somewhere in your dotemacs, which will revert the PDF-buffer
  280. *after* the TeX compilation has finished.
  281. #+BEGIN_SRC emacs-lisp
  282. (add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer)
  283. #+END_SRC
  284. ** Some keybindings
  285. | Navigation | |
  286. |--------------------------------------------+-----------------------|
  287. | Scroll Up / Down by page-full | ~space~ / ~backspace~ |
  288. | Scroll Up / Down by line | ~C-n~ / ~C-p~ |
  289. | Scroll Right / Left | ~C-f~ / ~C-b~ |
  290. | Top of Page / Bottom of Page | ~<~ / ~>~ |
  291. | Next Page / Previous Page | ~n~ / ~p~ |
  292. | First Page / Last Page | ~M-<~ / ~M->~ |
  293. | Incremental Search Forward / Backward | ~C-s~ / ~C-r~ |
  294. | Occur (list all lines containing a phrase) | ~M-s o~ |
  295. | Jump to Occur Line | ~RETURN~ |
  296. | Pick a Link and Jump | ~F~ |
  297. | Incremental Search in Links | ~f~ |
  298. | History Back / Forwards | ~B~ / ~N~ |
  299. | Display Outline | ~o~ |
  300. | Jump to Section from Outline | ~RETURN~ |
  301. | Jump to Page | ~M-g g~ |
  302. | Display | |
  303. |------------------------------------------+-----------------|
  304. | Zoom in / Zoom out | ~+~ / ~-~ |
  305. | Fit Height / Fit Width / Fit Page | ~H~ / ~W~ / ~P~ |
  306. | Trim margins (set slice to bounding box) | ~s b~ |
  307. | Reset margins | ~s r~ |
  308. | Reset Zoom | 0 |
  309. | Annotations | |
  310. |-------------------------------+-------------------------------------------------|
  311. | List Annotations | ~C-c C-a l~ |
  312. | Jump to Annotations from List | ~SPACE~ |
  313. | Mark Annotation for Deletion | ~d~ |
  314. | Delete Marked Annotations | ~x~ |
  315. | Unmark Annotations | ~u~ |
  316. | Close Annotation List | ~q~ |
  317. | Add and edit annotations | via Mouse selection and left-click context menu |
  318. | Syncing with Auctex | |
  319. |----------------------------------+-------------|
  320. | jump to PDF location from source | ~C-c C-g~ |
  321. | jump source location from PDF | ~C-mouse-1~ |
  322. | Miscellaneous | |
  323. |-----------------------------------------------+-----------|
  324. | Refresh File (e.g., after recompiling source) | ~g~ |
  325. | Print File | ~C-c C-p~ |
  326. # Local Variables:
  327. # mode: org
  328. # End: