📜  Doom emacs pdf-tools - Lisp (1)

📅  最后修改于: 2023-12-03 15:14:47.308000             🧑  作者: Mango

Doom emacs pdf-tools - Lisp

Introduction

Doom emacs pdf-tools is a powerful tool for programmers who want to work with PDF files within their Emacs environment. This package provides several features that can help programmers to read, annotate, and manipulate PDFs from directly within their workflow.

Features

The features provided by Doom emacs pdf-tools include the following:

  • PDF Viewing: The package offers a built-in PDF renderer that can display PDF files within the Emacs environment. The renderer is highly optimized and provides a smooth experience even for large and complex PDF documents.

  • Annotations: Users can add, edit, and delete annotations directly from within the PDF viewer. This includes support for text markup, highlighting, underlining, strikethrough, and adding notes.

  • PDF Editing: Users can edit PDF files using the package's built-in editing tools. This includes adding and removing pages, merging and splitting PDFs, and filling out and signing PDF forms.

  • Search and Navigation: The package provides powerful search and navigation capabilities that allow users to quickly navigate to any part of a PDF document. The package also supports full-text searching across multiple PDF files.

Installation

To install Doom emacs pdf-tools, follow these steps:

  1. Install Emacs: If you haven't already, download and install Emacs from the official website.

  2. Install Doom emacs: Follow the instructions on the official Doom emacs website to download and install the framework.

  3. Install pdf-tools: Open a terminal and run the command M-x package-install [RET] pdf-tools [RET] to install the pdf-tools package.

  4. Install poppler: pdf-tools requires the poppler library to work properly. Depending on your operating system, you may need to install poppler separately. On Ubuntu, you can run sudo apt-get install -y poppler-utils to install poppler.

Configuration

To configure Doom emacs pdf-tools, add the following lines to your Doom emacs configuration file:

(use-package pdf-tools
  :ensure t
  :config
  (pdf-tools-install))

;; Use pdf-view-mode
(add-to-list 'auto-mode-alist '("\\.pdf\\'" . pdf-view-mode))

;; Faster scrolling
(setq pdf-view-use-unicode-ligther nil
      pdf-view-resize-factor 1.10
      pdf-view-midnight-colors '("#b2b2b2" . "#282828" . "#444444"))

;; Add key-bindings
(define-key pdf-view-mode-map (kbd "j") 'pdf-view-next-line-or-next-page)
(define-key pdf-view-mode-map (kbd "k") 'pdf-view-previous-line-or-previous-page)
(define-key pdf-view-mode-map (kbd "t") 'pdf-annot-add-text-annotation)
(define-key pdf-view-mode-map (kbd "h") 'pdf-annot-add-highlight-markup-annotation)
(define-key pdf-view-mode-map (kbd "u") 'pdf-annot-add-underline-markup-annotation)
(define-key pdf-view-mode-map (kbd "s") 'pdf-annot-add-squiggly-markup-annotation)
(define-key pdf-view-mode-map (kbd "d") 'pdf-annot-delete)

;; pdfgrep integration
(setq pdf-info-epdfinfo-program "/usr/bin/epdfinfo")
(global-set-key (kbd "C-c C-g") 'pdfgrep)

Usage

To open a PDF file, simply open the file in Emacs using C-x C-f and then press RET to confirm. The PDF document will automatically open in pdf-view-mode.

To navigate through the document, use the standard Emacs navigation keys (i.e. C-v for scrolling down, M-v for scrolling up, C-l to recenter the screen).

To add an annotation, move the cursor to the location where you want to add the note and then use one of the keybindings defined in the configuration section above (i.e. t for text annotations, h for highlight annotations, etc.).

To edit a PDF file, use the built-in editing tools provided by the package. For example, use M-x pdf-tools-insert-page to add a new page, or use M-x pdf-tools-delete-region to delete a specific section of the document.

Conclusion

Doom emacs pdf-tools is a powerful tool that allows programmers to work with PDFs from within their Emacs environment. With its built-in PDF renderer, annotation tools, and editing features, pdf-tools provides everything you need to read, annotate, and manipulate PDF documents directly in your workflow.