Function: pdf-info-setoptions

pdf-info-setoptions is a natively compiled function defined in pdf-info.el.

Signature

(pdf-info-setoptions &optional FILE-OR-BUFFER &rest OPTIONS)

Source Code

;; Defined in /nix/store/63h5z2vmzn0mfavcxi2idi23g5xcgkbl-emacs-packages-deps/share/emacs/site-lisp/elpa/pdf-tools-20260102.1101/pdf-info.el
(defun pdf-info-setoptions (&optional file-or-buffer &rest options)
  (when (symbolp file-or-buffer)
    (push file-or-buffer options)
    (setq file-or-buffer nil))
  (unless (= (% (length options) 2) 0)
    (error "Missing a option value"))
  (apply #'pdf-info-query
    'setoptions
    (pdf-info--normalize-file-or-buffer file-or-buffer)
    (let (soptions)
      (while options
        (let ((key (pop options))
              (value (pop options)))
          (unless (and (keywordp key)
                       (not (eq key :)))
            (error "Keyword expected: %s" key))
          (cl-case key
            ((:render/foreground :render/background)
             (push (pdf-util-hexcolor value)
                   soptions))
            ((:render/printed)
             (push (if value 1 0) soptions))
            ((:render/gammabeforeinvert)
             (push (if value 1 0) soptions))
            ((:render/usecolors)
             ;; 0 -> original color
             ;; 1 -> recolor document to grayscale mapping black to
             ;;      :render/foreground and white to :render/background
             ;; 2 -> recolor document by inverting the perceived lightness
             ;;      preserving hue
             (push (if (and (integerp value) (> 3 value 0)) value 0)
                   soptions))
            (t (push value soptions)))
          (push key soptions)))
      soptions)))