top  Index  Search  Changes  RSS  Login

OpenPDF

PDF ファイルの指定ページへリンクしたい - 2ch3:212

;; 「>>> foo.pdf 3」上で RET を叩くと foo.pdf の 3 ページ目を開く
;; howm-test061216 でテスト
(setq my-action-lock-pdf-rule
  (let* ((reg0 "\\(\\(.+[.]pdf\\)\\( +[0-9]+\\)?\\)")
         (reg1 (concat ">>> +" reg0 " *$"))
         (both-pos 1)
         (file-pos 2)
         (page-pos 3))
    (action-lock-general
      `(lambda (both)
         (and (string-match ,reg0 both)
              (let* ((file (match-string-no-properties ,file-pos both))
                     (page (match-string-no-properties ,page-pos both))
                     (args (cons (expand-file-name file)
                                 (and page (list page)))))
                (apply #'start-process
                       (append '("my-open-pdf" nil "xpdf") args)))))
      reg1 both-pos)))
(add-to-list 'action-lock-default-rules my-action-lock-pdf-rule)

(Please LogIn to post comments.)

evince用

;; debian experimental上のevince-0.6.1上でのみ動作確認
;; evinceが対応しているpdf,ps,djvu,tiff,dviに対応したつもり
(setq my-action-lock-pdf-rule
  (let* ((reg0 "\\(\\(.+[.]\\(pdf\\|ps\\|djvu\\|tiff\\|dvi\\)\\)[ \t]?\\([0-9]+\\)?\\)")
         (reg1 (concat ">>> +" reg0 " *$"))
         (both-pos 1)
         (file-pos 2)
         (page-pos 4))
    (action-lock-general
     `(lambda (both)
         (and (string-match ,reg0 both)
              (let* ((file (match-string-no-properties ,file-pos both))
                     (page (match-string-no-properties ,page-pos both))
                     (args (cons (expand-file-name file)
                                 (list (concat "--page-label=" (or page "1"))))))
                (apply #'start-process
                       (append '("evince" nil "evince") args)))))
      reg1 both-pos)))
(add-to-list 'action-lock-default-rules my-action-lock-pdf-rule)

ページを指定しないときは1ページ目を開く仕様にしてあります。


(Please LogIn to post comments.)

Adobe Acrobat用

;; Windows上のAdobe Acrobat Professional8.0でのみ動作確認
(setq my-action-lock-pdf-rule
  (let* ((reg0 "\\(\\(.+[.]pdf\\)[ \t]?\\([0-9]+\\)?\\)")
         (reg1 (concat ">>> " reg0 " *$"))
         (both-pos 1)
         (file-pos 2)
         (page-pos 3))
    (action-lock-general
      `(lambda (both)
         (and (string-match ,reg0 both)
              (let* ((file (match-string-no-properties ,file-pos both))
                     (page (match-string-no-properties ,page-pos both))
                     (filename
                      (if (eq window-system 'w32)
                          (unix-to-dos-filename (expand-file-name file))
                        (expand-file-name file)))
                     (args (list
                            "/A"
                            (concat "page=" page)
                            filename
                            )))
                (apply #'start-process
                       (append '("acrobat" nil "c:/Program Files/Adobe/Acrobat 8.0/Acrobat/Acrobat.exe") args)))))
      reg1 both-pos)))
(add-to-list 'action-lock-default-rules my-action-lock-pdf-rule)

(Please LogIn to post comments.)

Last modified:2008/03/09 14:08:56
Keyword(s):
References:[なんでも]