Function: doc-view-get-bounding-box

doc-view-get-bounding-box is a byte-compiled function defined in doc-view.el.gz.

Signature

(doc-view-get-bounding-box)

Documentation

Get the BoundingBox information of the current page.

Source Code

;; Defined in /usr/src/emacs/lisp/doc-view.el.gz
(defun doc-view-get-bounding-box ()
  "Get the BoundingBox information of the current page."
  (let ((page (doc-view-current-page))
	(doc (let ((cache-doc (doc-view-current-cache-doc-pdf)))
	       (if (file-exists-p cache-doc)
		   cache-doc
		 doc-view--buffer-file-name))))
    (with-temp-buffer
      (when (eq 0 (ignore-errors
		    (process-file doc-view-ghostscript-program nil t
				  nil "-dSAFER" "-dBATCH" "-dNOPAUSE" "-q"
				  "-sDEVICE=bbox"
				  (format "-dFirstPage=%s" page)
				  (format "-dLastPage=%s" page)
				  doc)))
	(goto-char (point-min))
	(save-match-data
	  (when (re-search-forward
		 (concat "%%BoundingBox: "
			 "\\([[:digit:]]+\\) \\([[:digit:]]+\\) "
			 "\\([[:digit:]]+\\) \\([[:digit:]]+\\)")
                 nil t)
	    (mapcar #'string-to-number
		    (list (match-string 1)
			  (match-string 2)
			  (match-string 3)
			  (match-string 4)))))))))