| 1 |
;; -*- mode: lisp-interaction; syntax: elisp; coding: iso-2022-7bit -*- |
| 2 |
|
| 3 |
;; pdf-preview.el : preview text from the buffer as pdf files through PostScript |
| 4 |
;; Version 1.0.4 |
| 5 |
;; |
| 6 |
;; Copyright (C) 2004-2005 by T. Hiromatsu <matsuan@users.sourceforge.jp> |
| 7 |
|
| 8 |
;;; Commentary: |
| 9 |
|
| 10 |
;; Comments, questions and feedback will be sent to an english list |
| 11 |
;; <http://lists.sourceforge.jp/mailman/listinfo/macemacsjp-english> |
| 12 |
;; of MacEmacs JP project <http://macemacsjp.sourceforge.jp/en/>. |
| 13 |
;;---------------------------------------------------------------------- |
| 14 |
;; This program is free software; you can redistribute it and/or |
| 15 |
;; modify it under the terms of the GNU General Public License |
| 16 |
;; as published by the Free Software Foundation; either version 2 |
| 17 |
;; of the License, or (at your option) any later version. |
| 18 |
;; |
| 19 |
;; This program is distributed in the hope that it will be useful, |
| 20 |
;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 |
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 |
;; GNU General Public License for more details. |
| 23 |
;; |
| 24 |
;; The GNU General Public License can be gotten from |
| 25 |
;; the Free Software Foundation, Inc., |
| 26 |
;; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 27 |
;; http://www.gnu.org/licenses/gpl.html |
| 28 |
;; |
| 29 |
;;---------------------------------------------------------------------- |
| 30 |
;; 本プログラムはフリ・踉察?逅札愁侫肇?逅札Γ街札???です。 |
| 31 |
;; う髟阡擦覆燭蓮???Free Software Foundationが公表したGNU 一般公有使用許諾の |
| 32 |
;; 「バ・踉札献腑鵤押廾燭い呂修谿聞澆粒謄弌??ジョンの中からいずれかを選択し・髟阡 |
| 33 |
;; そのバ・踉札献腑鵑?蠅瓩襴苳賜項に拾苳擦辰橡椒廛蹈哀薀爐 |
| 34 |
;; 再頒布または変更することができます。 |
| 35 |
;; |
| 36 |
;; 本プログラムは有用とは思いますが・髟阡使夘曚砲???たっては・髟阡 |
| 37 |
;; 市??貔?擇啼団衞榲??臉?砲弔い討琉徒曚諒檸苳孜を含めて・髟阡 |
| 38 |
;; いかなる保??擇盥圓覆い泙擦鵝 |
| 39 |
;; ??楮戮砲弔い討GNU 一般公有使用許諾書をお読みください。 |
| 40 |
;; |
| 41 |
;; GNU一般公有使用許諾は・髟阡察 |
| 42 |
;; Free Software Foundation, |
| 43 |
;; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
| 44 |
;; http://www.gnu.org/licenses/gpl.html |
| 45 |
;; から入??蟆椎修任后 |
| 46 |
;; |
| 47 |
;;---------------------------------------------------------------------- |
| 48 |
;; 1. Features |
| 49 |
;; |
| 50 |
;; This package requires Multilingual Ghostscript. I suggest to |
| 51 |
;; use the package provided by Dr. Ogawa (Kumamoto Gakuen |
| 52 |
;; University). |
| 53 |
;; http://www2.kumagaku.ac.jp/teacher/herogw/index.html |
| 54 |
;; http://www2.kumagaku.ac.jp/teacher/herogw/archive/gplgs041101.dmg |
| 55 |
;; |
| 56 |
;; 1) Print texts in Emacs buffer through PostScript format as |
| 57 |
;; pdf(portable document format) file, then show it by |
| 58 |
;; adequate viewer. By default, GhostScript (ps2pdf13) will |
| 59 |
;; be used for transform from PostScript to pdf. |
| 60 |
;; 2) Make cjk font width 2 times as ascii font. |
| 61 |
;; 3) enable to input some parameters interactively. |
| 62 |
;; |
| 63 |
;; 2. Functions |
| 64 |
;; Totally 10 interactive functions are defined. Main 8 functions |
| 65 |
;; has names similar like as ps-print-* functions. |
| 66 |
;; |
| 67 |
;; pdf-preview-spool-buffer |
| 68 |
;; pdf-preview-spool-buffer-with-faces |
| 69 |
;; pdf-preview-spool-region |
| 70 |
;; pdf-preview-spool-region-with-faces |
| 71 |
;; |
| 72 |
;; These 4 functions make PostScript buffer "*PostScript*" by |
| 73 |
;; calling ps-spool-* functions after getting parameters |
| 74 |
;; interactively. |
| 75 |
;; |
| 76 |
;; pdf-preview-buffer |
| 77 |
;; pdf-preview-buffer-with-faces |
| 78 |
;; pdf-preview-region |
| 79 |
;; pdf-preview-region-with-faces |
| 80 |
;; |
| 81 |
;; These 4 functions compensate font width of CJK fonts (multipe |
| 82 |
;; by 1.2) to have 2 times width of ascii by calling |
| 83 |
;; pdf-preview-rescale-mule-font, then make pdf files through |
| 84 |
;; temporal PostScript file by pdf-preview-do-despool. |
| 85 |
;; |
| 86 |
;; pdf-preview-rescale-mule-font |
| 87 |
;; |
| 88 |
;; Compensate font width of CJK fonts (multipe by 1.2) to have 2 |
| 89 |
;; times width of ascii on "*PostScript*" buffer. |
| 90 |
;; |
| 91 |
;; pdf-preview-do-despool |
| 92 |
;; |
| 93 |
;; Make and preview pdf files through temporal PostScript file. |
| 94 |
;; |
| 95 |
;; 3. Usage |
| 96 |
;; usage1: call interactively |
| 97 |
;; M-x pdf-preview-(buffer|region)(-with-faces) |
| 98 |
;; |
| 99 |
;; usage2: call interactively with prefix argument |
| 100 |
;; C-u M-x pdf-preview-(buffer|region)(-with-faces) |
| 101 |
;; You can set some factors interactively shown as follows. |
| 102 |
;; ps-paper-type (Paper Size) |
| 103 |
;; ps-landscape-mode (Paper Direction) |
| 104 |
;; ps-print-header (Title on/off) |
| 105 |
;; pdf-preview-font-rescale-factor (Font Rescale Factor) |
| 106 |
;; ps-line-spacing (Linse Spacing) |
| 107 |
;; |
| 108 |
;; usage3: |
| 109 |
;; (pdf-preview-buffer arg-list) |
| 110 |
;; arg-list contains |
| 111 |
;; (ps-paper-type ps-landscape-mode |
| 112 |
;; ps-print-header pdf-preview-font-rescale-factor ps-line-spacing). |
| 113 |
;; |
| 114 |
;; example ; (pdf-preview-buffer '(a3 t nil 8 6)) |
| 115 |
;; |
| 116 |
;; 4. variables |
| 117 |
;; 1) pdf-preview-ps2pdf-command |
| 118 |
;; command for ps2pdf (transform Postscript to Portable Document Format) |
| 119 |
;; default : "ps2pdf13" |
| 120 |
;; |
| 121 |
;; 2) pdf-preview-ps2pdf-paper-size-option |
| 122 |
;; option for paper size of pdf-preview-ps2pdf-command |
| 123 |
;; default : "-sPAPERSIZE=" |
| 124 |
;; |
| 125 |
;; 3) pdf-preview-preview-command |
| 126 |
;; command for launching pdf viewer |
| 127 |
;; default : |
| 128 |
;; windows + CMD.EXE --- "start" |
| 129 |
;; windows + cygwin --- "cygstart" |
| 130 |
;; carbon-emacs --- "open" |
| 131 |
;; others --- "xpdf" |
| 132 |
;; |
| 133 |
;; 4) pdf-preview-font-rescale-factor |
| 134 |
;; rescale factor of font size defined in ps-print package |
| 135 |
;; default : 1.0 |
| 136 |
;; |
| 137 |
;;---------------------------------------------------------------------- |
| 138 |
;; |
| 139 |
;; 1. 機能 |
| 140 |
;; |
| 141 |
;; このパッケ・踉札犬鮖箸?逅三戮砲蓮???多言語化された・髟阡Ghostscript が必要です。 |
| 142 |
;; 窪3校本学園大学の・髟阡殺苳皿川先生が提供されている・髟阡札僖奪院??ジなどがお勧めです。 |
| 143 |
;; http://www2.kumagaku.ac.jp/teacher/herogw/index.html |
| 144 |
;; |
| 145 |
;; 1) Emacs の バッファ・踉擦離謄?好箸髻???PostScript format を経由して・髟阡 |
| 146 |
;; pdf に変換し・髟阡仕??淵咼絅錙??を使って表??┐靴泙后 |
| 147 |
;; Default では・髟阡GhostScript (ps2pdf13) を使っています。 |
| 148 |
;; 2) 日本語フォントとウ髟阡札好???フォントの幅を 2:1 に設定します。 |
| 149 |
;; 3) プレフィックス付きで呼び出すと・髟阡惨?弔?旅猝椶鯊佻壇?棒瀋蠅任?泙后 |
| 150 |
;; |
| 151 |
;; 2. 関数 |
| 152 |
;; ??腓粉愎瑤蓮???以王踉擦8個。各々の差は・髟阡ps-print(spool系の関数と同じ |
| 153 |
;; |
| 154 |
;; pdf-preview-spool-buffer |
| 155 |
;; pdf-preview-spool-buffer-with-faces |
| 156 |
;; pdf-preview-spool-region |
| 157 |
;; pdf-preview-spool-region-with-faces |
| 158 |
;; ??綉4関数は・髟阡interactiveに変数を??萋世靴職苳糸・髟阡ps-spool-* でPostScript |
| 159 |
;; フォ・踉札泪奪箸buffer(*PostScript)を作成します。 |
| 160 |
;; |
| 161 |
;; pdf-preview-buffer |
| 162 |
;; pdf-preview-buffer-with-faces |
| 163 |
;; pdf-preview-region |
| 164 |
;; pdf-preview-region-with-faces |
| 165 |
;; ??綉4関数は・髟阡ps-preview-spool-* でspoolした・髟阡PostScriptフォ・踉札泪奪箸紡个掘??? |
| 166 |
;; 関数 pdf-preview-rescale-mule-font |
| 167 |
;; を使って・髟阡Mule Font のみ 1.2 倍(所謂当幅にする為)した後・髟阡 |
| 168 |
;; 関数 pdf-preview-do-despool |
| 169 |
;; で・髟阡pdfファイルを作成します。 |
| 170 |
;; |
| 171 |
;; 3. 使い方 |
| 172 |
;; |
| 173 |
;; 1) M-x pdf-preview-(buffer|region)(-with-faces) |
| 174 |
;; 初期設定値で・髟阡ps・髟阡pdf ファイルが作られます。 |
| 175 |
;; |
| 176 |
;; 2) C-u M-x pdf-preview-(buffer|region)(-with-faces) |
| 177 |
;; 王踉撒?猝椶髻???対話的に設定できます。 |
| 178 |
;; 紙サイズ (ps-paper-type) |
| 179 |
;; 'b5, 'b4, 'a4small, 'ledger, 'lettersmall, 'legal, |
| 180 |
;; 'letter, 'a3, 'a4, |
| 181 |
;; 紙の向き (ps-landscape-mode) |
| 182 |
;; 'Landscape, 'Portrait, |
| 183 |
;; ヘッダ・踉擦陵? (ps-preint-header) |
| 184 |
;; 't, 'nil, |
| 185 |
;; フォントサイズの拡大比率 (pdf-preview-font-rexcale-factor) |
| 186 |
;; 任意の正の数 |
| 187 |
;; 行間隔 (ps-line-spacing) |
| 188 |
;; 任意の正の数 |
| 189 |
;; |
| 190 |
;; 3) (pdf-preview-buffer arg-list) |
| 191 |
;; 引数付きで関数呼び出し。引数は・髟阡殺苳糸記の5項目を含んだリストでう髟阡擦觧? |
| 192 |
;; 例 ; (pdf-preview-buffer '(a3 t nil 8 10)) |
| 193 |
;; a3・髟阡参C屬?如???ヘッダ・踉嗣気掘???フォントサイズは標準の8倍 |
| 194 |
;; 行間隔は 10/72 inch |
| 195 |
;; |
| 196 |
;; 4. 設定可能な変数 |
| 197 |
;; 1) pdf-preview-ps2pdf-command |
| 198 |
;; ps2pdf に使う瘢雹コマンド |
| 199 |
;; デフォルト : "ps2pdf13" |
| 200 |
;; |
| 201 |
;; * 私は・髟阡cjkps2pdf.pl を使ったりしているので・髟阡 |
| 202 |
;; "perl ~/bin/cjkps2pdf.pl --keepmetrics" |
| 203 |
;; にしています。 |
| 204 |
;; |
| 205 |
;; 2) pdf-preview-ps2pdf-paper-size-option |
| 206 |
;; pdf-preview-ps2pdf-command で・髟阡算罐汽ぅ困了慊蠅忙箸?逅札?廛轡腑 |
| 207 |
;; デフォルト : "-sPAPERSIZE=" |
| 208 |
;; |
| 209 |
;; * 私は・髟阡cjkps2pdf.pl を使ったりしているので・髟阡 |
| 210 |
;; "--papersize " |
| 211 |
;; にしています。 |
| 212 |
;; |
| 213 |
;; 3) pdf-preview-preview-command |
| 214 |
;; プレビュワ・踉擦魑?阿垢襯灰泪鵐 |
| 215 |
;; デフォルト : |
| 216 |
;; windows + CMD.EXE --- "start" |
| 217 |
;; windows + cygwin --- "cygstart" |
| 218 |
;; carbon-emacs --- "open" |
| 219 |
;; others --- "xpdf" |
| 220 |
;; |
| 221 |
;; 4) pdf-preview-font-rescale-factor |
| 222 |
;; フォントの拡大率 |
| 223 |
;; デフォルト : 1.0 |
| 224 |
;; |
| 225 |
;; * 私は・髟阡1.1 にしてます。 |
| 226 |
;; |
| 227 |
;; 5. 履歴 |
| 228 |
;; 1.0.4 2005-10-17 bug fix |
| 229 |
;; 1.0.3 2005-05-30 bug fix |
| 230 |
;; 1.0.2 2005-05-24 bug fix |
| 231 |
;; プレビュワ・踉札灰泪鵐匹離妊侫?襯斑佑OS毎に設定 |
| 232 |
;; 1.0.1 2005-05-23 .emacs の設定がなくても動くよう瘢雹に変更 |
| 233 |
;; 紙サイズA4, 行間隔6をデフォルトに |
| 234 |
;; 行間隔も対話的に設定できるよう瘢雹に |
| 235 |
;; 1.0.0 2005-05-20 リリ・踉札 |
| 236 |
|
| 237 |
;;; code |
| 238 |
|
| 239 |
;;; |
| 240 |
;;; initialize section |
| 241 |
;;; |
| 242 |
|
| 243 |
(if (not (boundp 'ps-paper-type)) (setq ps-paper-type 'a4)) |
| 244 |
(if (not (boundp 'ps-line-spacing)) (setq ps-line-spacing 6)) |
| 245 |
|
| 246 |
(require 'ps-print) |
| 247 |
(require 'ps-mule) |
| 248 |
|
| 249 |
(defalias 'ps-mule-header-string-charsets 'ignore) |
| 250 |
|
| 251 |
(defvar pdf-preview-ps2pdf-command "ps2pdf13") |
| 252 |
|
| 253 |
(defvar pdf-preview-ps2pdf-paper-size-option "-sPAPERSIZE=") |
| 254 |
|
| 255 |
(defvar pdf-preview-preview-command |
| 256 |
(cond |
| 257 |
((featurep 'dos-w32) |
| 258 |
(if (string-match "\\(cmdproxy\.exe$\\|cmd\.exe$\\)" shell-file-name) "start" |
| 259 |
"cygstart")) |
| 260 |
((featurep 'mac-carbon) "open") |
| 261 |
("xpdf"))) |
| 262 |
|
| 263 |
(defvar pdf-preview-ignored-papersize-list '("tabloid" "statement" "executive")) |
| 264 |
|
| 265 |
(defvar pdf-preview-font-rescale-factor 1.0) |
| 266 |
|
| 267 |
(defvar pdf-preview-ps-mule-search-word |
| 268 |
(concat "/f[89][29]-[0-2] \\([0-9]+\.[0-9][0-9][0-9][0-9][0-9][0-9]\\) /" |
| 269 |
"\\(Ryumin-Light\\|GothicBBB-Medium\\)" |
| 270 |
"\\(-H\\|\\.Katakana\\|\\.Hankaku\\) " |
| 271 |
"\\(DefFontMule\\)")) |
| 272 |
|
| 273 |
(defun pdf-preview-get-paper-size (paper-type) |
| 274 |
(downcase (nth 3 (or (assoc paper-type ps-page-dimensions-database) |
| 275 |
(assoc ps-paper-type ps-page-dimensions-database))))) |
| 276 |
|
| 277 |
(defvar pdf-preview-papersize-list |
| 278 |
(let ((lst |
| 279 |
(mapcar |
| 280 |
(function (lambda (s) (cons (car s) (pdf-preview-get-paper-size (car s))))) |
| 281 |
ps-page-dimensions-database))) |
| 282 |
(dolist (elt pdf-preview-ignored-papersize-list) (delete (rassoc elt lst) lst)) |
| 283 |
lst)) |
| 284 |
|
| 285 |
;;; |
| 286 |
;;; Function section |
| 287 |
;;; |
| 288 |
|
| 289 |
(defun pdf-preview-do-despool (&optional papersize) |
| 290 |
"Preview PostScript spool via PDF" |
| 291 |
(interactive (list (pdf-preview-papersize current-prefix-arg))) |
| 292 |
(let* ((ps-temp-file |
| 293 |
(concat (make-temp-name (concat temporary-file-directory "pdf")) ".ps")) |
| 294 |
(pdf-temp-file |
| 295 |
(concat (file-name-sans-extension ps-temp-file) ".pdf")) |
| 296 |
(paper |
| 297 |
(cdr (assoc (or papersize ps-paper-type) pdf-preview-papersize-list))) |
| 298 |
(ps2pdf-command |
| 299 |
(format "%s %s%s %s %s" pdf-preview-ps2pdf-command |
| 300 |
pdf-preview-ps2pdf-paper-size-option paper |
| 301 |
ps-temp-file pdf-temp-file)) |
| 302 |
(preview-command |
| 303 |
(format "%s %s" pdf-preview-preview-command pdf-temp-file))) |
| 304 |
(ps-do-despool ps-temp-file) |
| 305 |
(shell-command (concat ps2pdf-command " && " preview-command)))) |
| 306 |
|
| 307 |
(defun pdf-preview-rescale-mule-font (&optional arg) |
| 308 |
"Rescale mule fonts for keeping in line with ascii" |
| 309 |
(interactive) |
| 310 |
(save-excursion |
| 311 |
(set-buffer "*PostScript*") |
| 312 |
(goto-char (point-min)) |
| 313 |
(while (re-search-forward pdf-preview-ps-mule-search-word nil t) |
| 314 |
(let* ((end (match-end 4)) |
| 315 |
(num (buffer-substring (match-beginning 1) (match-end 1))) |
| 316 |
(str (format "%.6f" (* (string-to-number num) 1.2)))) |
| 317 |
(goto-char (match-beginning 1)) |
| 318 |
(delete-region (match-beginning 1) (match-end 1)) |
| 319 |
(insert str) |
| 320 |
(goto-char end))))) |
| 321 |
|
| 322 |
(defun pdf-preview-spool-buffer (&optional arg-list) |
| 323 |
"Generate and spool a PostScript image of the buffer for pdf preview." |
| 324 |
(interactive (pdf-preview-factor current-prefix-arg)) |
| 325 |
(pdf-preview-spool 'ps-spool-buffer arg-list)) |
| 326 |
|
| 327 |
(defun pdf-preview-buffer (&optional arg-list) |
| 328 |
"Generate and preview a pdf file of the buffer via PostScript." |
| 329 |
(interactive (pdf-preview-factor current-prefix-arg)) |
| 330 |
(pdf-preview-spool-buffer arg-list) |
| 331 |
(save-excursion (pdf-preview-rescale-mule-font)) |
| 332 |
(pdf-preview-do-despool (car arg-list))) |
| 333 |
|
| 334 |
(defun pdf-preview-spool-buffer-with-faces (&optional arg-list) |
| 335 |
"Generate and spool a PostScript image of the buffer with faces for pdf preview." |
| 336 |
(interactive (pdf-preview-factor current-prefix-arg)) |
| 337 |
(pdf-preview-spool 'ps-spool-buffer-with-faces arg-list)) |
| 338 |
|
| 339 |
(defun pdf-preview-buffer-with-faces (&optional arg-list) |
| 340 |
"Generate and preview a pdf file of the buffer with faces via PostScript." |
| 341 |
(interactive (pdf-preview-factor current-prefix-arg)) |
| 342 |
(pdf-preview-spool-buffer-with-faces arg-list) |
| 343 |
(save-excursion (pdf-preview-rescale-mule-font)) |
| 344 |
(pdf-preview-do-despool (car arg-list))) |
| 345 |
|
| 346 |
(defun pdf-preview-spool-region (from to &optional arg-list) |
| 347 |
"Generate and spool a PostScript image of the region for pdf preview." |
| 348 |
(interactive (pdf-preview-region-factor current-prefix-arg)) |
| 349 |
(pdf-preview-spool 'ps-spool-region arg-list from to)) |
| 350 |
|
| 351 |
(defun pdf-preview-region (from to &optional arg-list) |
| 352 |
"Generate and preview a pdf file of the region via PostScript." |
| 353 |
(interactive (pdf-preview-region-factor current-prefix-arg)) |
| 354 |
(pdf-preview-spool-region from to arg-list) |
| 355 |
(save-excursion (pdf-preview-rescale-mule-font)) |
| 356 |
(pdf-preview-do-despool (car arg-list))) |
| 357 |
|
| 358 |
(defun pdf-preview-spool-region-with-faces (from to &optional arg-list) |
| 359 |
"Generate and spool a PostScript image of the region with faces for pdf preview." |
| 360 |
(interactive (pdf-preview-region-factor current-prefix-arg)) |
| 361 |
(pdf-preview-spool 'ps-spool-region-with-faces arg-list from to)) |
| 362 |
|
| 363 |
(defun pdf-preview-region-with-faces (from to &optional arg-list) |
| 364 |
"Generate and preview a pdf file of the region with faces via PostScript." |
| 365 |
(interactive (pdf-preview-region-factor current-prefix-arg)) |
| 366 |
(pdf-preview-spool-region-with-faces from to arg-list) |
| 367 |
(save-excursion (pdf-preview-rescale-mule-font)) |
| 368 |
(pdf-preview-do-despool (car arg-list))) |
| 369 |
|
| 370 |
(defun pdf-preview-region-factor (prefix-arg) |
| 371 |
(let ((lst (car (pdf-preview-factor prefix-arg)))) |
| 372 |
(list (region-beginning) (region-end) lst))) |
| 373 |
|
| 374 |
(defun pdf-preview-papersize (prefix-arg) |
| 375 |
(and prefix-arg |
| 376 |
(or (numberp prefix-arg) (listp prefix-arg)) |
| 377 |
(let* ((prompt "Papersize : ") |
| 378 |
(completion-ignore-case t) |
| 379 |
(default (cdr (assoc ps-paper-type pdf-preview-papersize-list))) |
| 380 |
(lst (mapcar (lambda (ls) (cdr ls)) pdf-preview-papersize-list)) |
| 381 |
(str (completing-read prompt lst nil t default))) |
| 382 |
(car (rassoc str pdf-preview-papersize-list))))) |
| 383 |
|
| 384 |
(defun pdf-preview-factor (prefix-arg) |
| 385 |
(and prefix-arg |
| 386 |
(or (numberp prefix-arg) (listp prefix-arg)) |
| 387 |
(list |
| 388 |
(list |
| 389 |
(pdf-preview-papersize prefix-arg) |
| 390 |
(let* ((prompt (format "Direction : ")) |
| 391 |
(completion-ignore-case t) |
| 392 |
(default (if ps-landscape-mode "Landscape" "Portrait")) |
| 393 |
(lst '("Landscape" "Portrait")) |
| 394 |
(str (completing-read prompt lst nil t default))) |
| 395 |
(if (string-match str "Landscape") t nil)) |
| 396 |
(let* ((prompt (format "Print Title : ")) |
| 397 |
(completion-ignore-case t) |
| 398 |
(default (if ps-print-header "t" "nil")) |
| 399 |
(str (completing-read prompt '("t" "nil") nil t default))) |
| 400 |
(if (string-match str "t") t nil)) |
| 401 |
(let ((prompt (format "Font Rescale Factor : ")) |
| 402 |
(factor) |
| 403 |
(default (number-to-string pdf-preview-font-rescale-factor))) |
| 404 |
(while (not (numberp (setq factor (read-minibuffer prompt default))))) |
| 405 |
factor) |
| 406 |
(let ((prompt (format "Line Spacing : ")) |
| 407 |
(spacing) |
| 408 |
(default (number-to-string ps-line-spacing))) |
| 409 |
(while (not (numberp (setq spacing (read-minibuffer prompt default))))) |
| 410 |
spacing))))) |
| 411 |
|
| 412 |
(defun pdf-preview-mult (cons_cell factor) |
| 413 |
(if (numberp cons_cell) (* cons_cell factor) |
| 414 |
(cons (* factor (car cons_cell)) (* factor (cdr cons_cell))))) |
| 415 |
|
| 416 |
(defun pdf-preview-spool (pdf-preview-spool-function arg-list &optional from to) |
| 417 |
(save-excursion |
| 418 |
(let* ((ps-paper-type (if arg-list (nth 0 arg-list) ps-paper-type)) |
| 419 |
(ps-landscape-mode (if arg-list (nth 1 arg-list) ps-landscape-mode)) |
| 420 |
(ps-print-header (if arg-list (nth 2 arg-list) ps-print-header)) |
| 421 |
(factor (if arg-list (nth 3 arg-list) pdf-preview-font-rescale-factor)) |
| 422 |
(ps-line-spacing (if arg-list (nth 4 arg-list) ps-line-spacing)) |
| 423 |
(ps-font-size (pdf-preview-mult ps-font-size factor)) |
| 424 |
(ps-header-font-size (pdf-preview-mult ps-header-font-size factor)) |
| 425 |
(ps-footer-font-size (pdf-preview-mult ps-footer-font-size factor)) |
| 426 |
(ps-header-title-font-size |
| 427 |
(pdf-preview-mult ps-header-title-font-size factor)) |
| 428 |
(ps-line-number-font-size |
| 429 |
(pdf-preview-mult ps-line-number-font-size factor)) |
| 430 |
(ps-multibyte-buffer 'non-latin-printer)) |
| 431 |
(if from (funcall pdf-preview-spool-function from to) |
| 432 |
(funcall pdf-preview-spool-function))))) |
| 433 |
|
| 434 |
(provide 'pdf-preview) |
| 435 |
|
| 436 |
;;; pdf-preview.el ends here |