Function: doc-view-set-slice-from-bounding-box
doc-view-set-slice-from-bounding-box is an interactive and
byte-compiled function defined in doc-view.el.gz.
Signature
(doc-view-set-slice-from-bounding-box &optional FORCE-PAPER-SIZE)
Documentation
Set the slice from the document's BoundingBox information.
The result is that the margins are almost completely cropped,
much more accurate than could be done manually using
doc-view-set-slice-using-mouse.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/doc-view.el.gz
(defun doc-view-set-slice-from-bounding-box (&optional force-paper-size)
"Set the slice from the document's BoundingBox information.
The result is that the margins are almost completely cropped,
much more accurate than could be done manually using
`doc-view-set-slice-using-mouse'."
(interactive "P")
(let ((bb (doc-view-get-bounding-box)))
(if (not bb)
(message "BoundingBox couldn't be determined")
(let* ((is (image-size (doc-view-current-image) t))
(iw (car is))
(ih (cdr is))
(ps (or (and (null force-paper-size)
(doc-view-guess-paper-size iw ih))
(intern (completing-read "Paper size: "
doc-view-paper-sizes
nil t))))
(bb (doc-view-scale-bounding-box ps iw ih bb))
(x1 (nth 0 bb))
(y1 (nth 1 bb))
(x2 (nth 2 bb))
(y2 (nth 3 bb)))
;; We keep a 2 pixel margin.
(doc-view-set-slice (- x1 2) (- ih y2 2)
(+ (- x2 x1) 4) (+ (- y2 y1) 4))))))