Function: ps-nb-pages
ps-nb-pages is a byte-compiled function defined in ps-print.el.gz.
Signature
(ps-nb-pages NB-LINES)
Documentation
Display correspondence between font size and the number of pages.
The correspondence is based on having NB-LINES lines of text, and on the current ps-print setup.
Source Code
;; Defined in /usr/src/emacs/lisp/ps-print.el.gz
(defun ps-nb-pages (nb-lines)
"Display correspondence between font size and the number of pages.
The correspondence is based on having NB-LINES lines of text,
and on the current ps-print setup."
(let* ((ps-font-size-internal
(or ps-font-size-internal
(ps-get-font-size 'ps-font-size)))
(ps-header-font-size-internal
(or ps-header-font-size-internal
(ps-get-font-size 'ps-header-font-size)))
(ps-footer-font-size-internal
(or ps-footer-font-size-internal
(ps-get-font-size 'ps-footer-font-size)))
(ps-header-title-font-size-internal
(or ps-header-title-font-size-internal
(ps-get-font-size 'ps-header-title-font-size)))
(ps-line-spacing-internal
(or ps-line-spacing-internal
(ps-get-size ps-line-spacing "line spacing")))
(buf (get-buffer-create "*Nb-Pages*"))
(ils ps-line-spacing-internal) ; initial line spacing
(ifs ps-font-size-internal) ; initial font size
(page-height (progn (ps-get-page-dimensions)
ps-print-height))
(ilh (ps-line-height 'ps-font-for-text)) ; initial line height
(ps-setup (ps-setup)) ; setup for the current buffer
(fs-min 4) ; minimum font size
lh-min ; minimum line height
nb-lpp-max ; maximum nb of lines per page
nb-page-min ; minimum nb of pages
(fs-max 14) ; maximum font size
lh-max ; maximum line height
nb-lpp-min ; minimum nb of lines per page
nb-page-max ; maximum nb of pages
fs ; current font size
lh ; current line height
nb-lpp ; current nb of lines per page
nb-page ; current nb of pages
)
(setq lh-min (/ (- (* (+ ilh ils) fs-min) ils) ifs)
nb-lpp-max (floor (/ page-height lh-min))
nb-page-min (ceiling (/ (float nb-lines) nb-lpp-max))
lh-max (/ (- (* (+ ilh ils) fs-max) ils) ifs)
nb-lpp-min (floor (/ page-height lh-max))
nb-page-max (ceiling (/ (float nb-lines) nb-lpp-min))
nb-page nb-page-min)
(set-buffer buf)
(goto-char (point-max))
(or (bobp) (insert "\n" (make-string 75 ?\;) "\n"))
(insert ps-setup
(format "\nThere are %d lines.\n\n" nb-lines)
"nb page / font size\n")
(while (<= nb-page nb-page-max)
(setq nb-lpp (ceiling (/ nb-lines (float nb-page)))
lh (/ page-height nb-lpp)
fs (/ (* ifs lh) ilh))
(insert (format "%7d %s\n" nb-page fs))
(setq nb-page (1+ nb-page)))
(insert "\n")
(display-buffer buf 'not-this-window)))