[mew-dist 29313] Re: テキスト付きPDFをinli neで読むには

Hideyuki SHIRAI (白井秀行) <[email protected]> Tue, 25 Jan 2011 21:05:57 +0900 (JST)
Newsgroups gmane.mail.mew.general.japanese
Organization Resident at Meadowy farm.
Message-ID <[email protected]>

From: Harumitsu YOSHITAKE <[email protected]> 
Subject: [mew-dist 29312] PDFinline
Message-ID: <[email protected]>
Date: Mon, 24 Jan 2011 15:59:53 +0900 (JST)

> Ubuntu Server 10.10  mew  ssh 
>
>  Word  Excel inline 
>  wvHtml 
>
> PDF inline 
> 
>
> wvHtml  pdftotext 
> 
>
> elisp 
> 

# 

 pdftotext 
pdf2txt ( perl script) 


PDF  Viewer 


;; (setq mew-prog-pdf 'mew-mime-application/pdf)
(setq mew-prog-pdf '(nil mew-mime-application/pdf))
(setq mew-prog-application/pdf "pdftotext")

(defvar my-pdftotext-new t)

(defun mew-mime-application/pdf-ext (cache begin end &optional parameter)
  (with-current-buffer (mew-buffer-message)
    (mew-elet
     (mew-erase-buffer)
     (mew-mime-application/pdf cache begin end parameter)
     (mew-summary-display-postscript 'nohook))))

(defun mew-mime-application/pdf (cache begin end &optional parameter)
  (mew-erase-buffer)
  (let ((doit t) file1 file2
	(prog mew-prog-application/pdf))
    (unless (mew-which-exec prog)
      (setq doit nil)
      (mew-elet (insert "Install " prog "\n")))
    (if (not doit)
	(progn
	  (mew-elet (insert "\n"))
	  (mew-mime-part-messages nil))
      (setq file1 (mew-make-temp-name))
      (with-current-buffer cache
	(mew-flet
	 (write-region begin end file1 nil 'no-msg)))
      (setq file2 (mew-make-temp-name))
      (if (string= prog "pdf2txt")
	  (mew-frwlet
	      'shift_jis mew-cs-dummy
	    (call-process prog nil (current-buffer) nil "-s" file1))
	(mew-frwlet
	    'euc-japan mew-cs-dummy
	  (if my-pdftotext-new
	      (call-process prog nil nil nil "-raw" "-enc" "EUC-JP" file1 file2)
	    (call-process prog nil nil nil "-raw" "-eucjp" file1 file2))
	  (if (file-exists-p file2)
	      (insert-file-contents file2)
	    ;; passwd?
	    (mew-frwlet
		'shift_jis mew-cs-dummy
	      (call-process "pdf2txt" nil (current-buffer) nil "-s" file1)))))
      ;; (japanese-hankaku-region (point-min) (point-max) 'ascii)
      (if (file-exists-p file1) (delete-file file1))
      (if (file-exists-p file2) (delete-file file2)))))

-- 
 (mailto:[email protected])