Git Product home page Git Product logo

pdf-tools's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

aikrahguzar

pdf-tools's Issues

Error message after setting 'pdf-annot-activate-created-annotations t'

Bit of a noob at this so apologies in advance for any mistakes. Firstly, thank you for your work here!

I seem to be having a (small) issue. When I set:

  • (setq pdf-annot-activate-created-annotations t)

And I want to proceed by highlighting and annotating a sentence in a PDF, I am still able to do so, but I get error message "nth: Wrong type argument: numberp, nil". Any idea how to fix this/circumvent this message?

My configuration for pdf-tools using straight is below:

(use-package pdf-tools
  :straight '(pdf-tools :type git :host github
                        :repo "vedang/pdf-tools"
                        :fork (:host github
                                     :repo "orgtre/pdf-tools"))
  :defer t 
  :bind (:map pdf-view-mode-map
              ("j" . pdf-view-next-line-or-next-page)
              ("k" . pdf-view-previous-line-or-previous-page)
              ("h" . image-backward-hscroll)
              ("l" . image-forward-hscroll)
              ("d" . pdf-view-midnight-minor-mode)
              ("i" . consult-imenu)
              ("C-c C-r M" . pdf-view-remove-margins-mode))
  :mode ("\\.[pP][dD][fF]\\'" . pdf-view-mode)    
  :magic ("%PDF" . pdf-view-mode)
  :custom
  (pdf-view-display-size 'fit-page)
  (pdf-view-resize-factor 1.1)
  (pdf-view-use-unicode-ligther nil)

  ;; LaTeX
  (TeX-view-program-selection '((output-pdf "PDF Tools")))
  (TeX-view-program-list '(("PDF Tools" TeX-pdf-tools-sync-view)))
  (TeX-source-correlate-start-server t)

  ;; pdf-annot
  (pdf-annot-minor-mode-map-prefix "a")
  (pdf-annot-list-format '((page . 3) (type . 7) (contents . 200)))
  (pdf-annot-activate-created-annotations t)

  ;; pdf-outline
  (pdf-outline-imenu-use-flat-menus t)

  ;; pdf-keynav
  (pdf-keynav-copy-region-blink-delay 2)
  (pdf-keynav-transient-mark-mode t)

  :init
  ;; Dealing with retina issues on MacOs
  (when *sys/mac*
    (setq pdf-view-use-scaling t)
    (setq pdf-view-use-imagemagick nil))

  (pdf-tools-install :no-query)
  :config
  (define-pdf-cache-function pagelabels)
  (add-to-list 'pdf-tools-enabled-modes 'pdf-virtual-global-minor-mode)
  (add-to-list 'pdf-tools-enabled-modes 'pdf-keynav-minor-mode)
  
  ;;; Define functions
  (defun pdf-outline-indent (fn link &optional labels)
    (let ((item (funcall fn link labels))
          (indent pdf-outline-buffer-indent))
      (cons (concat (make-string (* indent (1- (alist-get 'depth link))) ?\s)
                    (car item))
            (cdr item))))
  (advice-add 'pdf-outline-imenu-create-item :around #'pdf-outline-indent)

  (defun pdf-view-midnight-colors-theme ()
    (cons (frame-parameter nil 'foreground-color)
          (color-darken-name
           (frame-parameter nil 'background-color) 5)))

  (defun ctb/pdf-tools-backdrop ()
    (face-remap-add-relative
     'default
     `(:background ,(modus-themes-color 'bg-alt))))
  (defun ctb/pdf-tools-midnight-mode-toggle ()
    (when (derived-mode-p 'pdf-view-mode)
      (if (eq (car custom-enabled-themes) 'modus-vivendi)
          (pdf-view-midnight-minor-mode 1)
        (pdf-view-midnight-minor-mode -1))
      (ctb/pdf-tools-backdrop)))

  ;; Other customizations: modeline and removing margins
  (defun mode-line-extra-pdf-view-mode ()
    (let ((cur (number-to-string (pdf-view-current-page)))
          (tot (or (ignore-errors (number-to-string (pdf-cache-number-of-pages)))
                   "???")))
      (format "(%s/%s)" cur tot)))

  (define-minor-mode pdf-view-remove-margins-mode
    "Minor mode for removing margins from every pdf page."
    :lighter " pdf-margins"
    (if (not (eq major-mode 'pdf-view-mode))
        (user-error "Not in a pdf-view-mode buffer")
      (if pdf-view-remove-margins-mode
          (progn
            (pdf-view-set-slice-from-bounding-box)
            (add-hook 'pdf-view-after-change-page-hook #'pdf-view-set-slice-from-bounding-box))
        (progn
          (pdf-view-reset-slice)
          (remove-hook
           'pdf-view-after-change-page-hook #'pdf-view-set-slice-from-bounding-box)))))

  :hook (
         ;; (pdf-view-mode-hook . (lambda() (linum-mode -1)))
         ;; (pdf-view-mode-hook . (lambda () (display-line-numbers-mode -1)))
         (pdf-view-mode-hook . pdf-tools-enable-minor-modes)
         (modus-themes-after-load-theme-hook . ctb/pdf-tools-midnight-mode-toggle)
         (pdf-view-mode-hook . ctb/pdf-tools-midnight-mode-toggle)
         (pdf-view-midnight-mode-hook . pdf-view-midnight-colors-theme)
         (TeX-after-compilation-finished-functions . TeX-revert-document-buffer)))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.