politza / pdf-tools

Emacs support library for PDF files.
GNU General Public License v3.0
1.57k stars 162 forks source link

Feature Request: a way to change highlight colors #581

Closed notuntoward closed 2 years ago

notuntoward commented 4 years ago

Love the fact that I can now annotate pdfs in Emacs!

But I have a feature request: in other pdf annotators, I've stuck with a color system for highlighting and underlines: green is for definitions, orange is for emphasis, blue is for important figure numbers, etc.

A color switcher UI might be a bit too much to ask, but would it be at least possible to add customizations for the highlighter and underliner colors?

vnckppl commented 4 years ago

You can add the following to your setup to set default colors for all different annotation styles:

  ;; Default annotation colors

;; Strike out
  (defun pdftools-strikeout-gray (oldfun loe)
    (apply oldfun loe '("gray")))
  (advice-add 'pdf-annot-add-strikeout-markup-annotation :around 
              #'pdftools-strikeout-gray)

  ;; Underline
  (defun pdftools-underline-purple (oldfun loe)
    (apply oldfun loe '("#8a1e8a")))
  (advice-add 'pdf-annot-add-underline-markup-annotation :around 
              #'pdftools-underline-purple)

  ;; Squiggly underline
  (defun pdftools-squiggly-red (oldfun loe)
    (apply oldfun loe '("#fe2500")))
  (advice-add 'pdf-annot-add-squiggly-markup-annotation :around 
              #'pdftools-squiggly-red)

  ;; This will change the color of the annotation.
  (setq pdf-annot-default-markup-annotation-properties
        '((color . "yellow")))

  ;; This will change the color of the Note.
  (setq pdf-annot-default-text-annotation-properties
        '((color . "#90ee90")))

Some credit goes to brittAnderson.

notuntoward commented 4 years ago

Thanks much, that's a good start towards towards some kind of color switcher UI.

dalanicolai commented 4 years ago

You can customize pdf-annot-default-annotation-properties, pdf-annot-default-markup-annotation-properties and pdf-annot-default-text-annotation-properties via the customization menu.