Function: pdf-info-check-epdfinfo

pdf-info-check-epdfinfo is an interactive and natively compiled function defined in pdf-info.el.

Signature

(pdf-info-check-epdfinfo &optional INTERACTIVE-P)

Documentation

Check if the server should be working properly.

Signal an error if some problem was found. Message a confirmation, if INTERACTIVE-P is non-nil and no problems were found.

Returns nil.

Key Bindings

This command is not in any keymaps.

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-check-epdfinfo (&optional interactive-p)
  "Check if the server should be working properly.

Signal an error if some problem was found.  Message a
confirmation, if INTERACTIVE-P is non-nil and no problems were
found.

Returns nil."
  (interactive "p")
  (let ((executable pdf-info-epdfinfo-program))
    (unless (stringp executable)
      (error "pdf-info-epdfinfo-program is unset or not a string"))
    (unless (file-executable-p executable)
      (error "pdf-info-epdfinfo-program is not executable"))
    (when pdf-info-epdfinfo-error-filename
      (unless (and (stringp pdf-info-epdfinfo-error-filename)
                   (file-writable-p pdf-info-epdfinfo-error-filename))
        (error "pdf-info-epdfinfo-error-filename should contain writable filename")))
    (let* ((default-directory (expand-file-name "~/"))
           (cmdfile (make-temp-file "commands"))
           (pdffile (make-temp-file "empty.pdf"))
           (tempdir (make-temp-file "tmpdir" t))
           (process-environment (cons (concat "TMPDIR=" tempdir)
                                      process-environment)))
      (unwind-protect
          (with-temp-buffer
            (with-temp-file pdffile
              (set-buffer-multibyte nil)
              (insert pdf-info-empty-page-data))
            (with-temp-file cmdfile
              (insert (format "renderpage:%s:1:100\nquit\n"
                              (pdf-info-query--escape pdffile))))
            (unless (= 0 (apply #'call-process
                                executable cmdfile (current-buffer)
                                nil (when pdf-info-epdfinfo-error-filename
                                      (list pdf-info-epdfinfo-error-filename))))
              (error "Error running `%s': %s"
                     pdf-info-epdfinfo-program
                     (buffer-string))))
        (when (file-exists-p cmdfile)
          (delete-file cmdfile))
        (when (file-exists-p pdffile)
          (delete-file pdffile))
        (when (file-exists-p tempdir)
          (delete-directory tempdir t)))))
  (when interactive-p
    (message "The epdfinfo program appears to be working."))
  nil)