[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r111462: * lisp/doc-view.el: Add supp
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r111462: * lisp/doc-view.el: Add support for mupdf converter. |
Date: |
Wed, 09 Jan 2013 14:48:42 -0500 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 111462
fixes bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13164
author: Elias Pipping <address@hidden>
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Wed 2013-01-09 14:48:42 -0500
message:
* lisp/doc-view.el: Add support for mupdf converter.
(doc-view-pdfdraw-program, doc-view-pdf->png-converter-function)
(doc-view-ps->png-converter-function): New config vars.
(doc-view-pdf->png-converter-ghostscript)
(doc-view-ps->png-converter-ghostscript)
(doc-view-pdf->png-converter-mupdf): New functions.
(doc-view-pdf/ps->png, doc-view-pdf->png-1): Use them.
modified:
lisp/ChangeLog
lisp/doc-view.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2013-01-09 09:49:27 +0000
+++ b/lisp/ChangeLog 2013-01-09 19:48:42 +0000
@@ -1,3 +1,13 @@
+2013-01-09 Elias Pipping <address@hidden>
+
+ * doc-view.el: Add support for mupdf converter (bug#13164).
+ (doc-view-pdfdraw-program, doc-view-pdf->png-converter-function)
+ (doc-view-ps->png-converter-function): New config vars.
+ (doc-view-pdf->png-converter-ghostscript)
+ (doc-view-ps->png-converter-ghostscript)
+ (doc-view-pdf->png-converter-mupdf): New functions.
+ (doc-view-pdf/ps->png, doc-view-pdf->png-1): Use them.
+
2013-01-09 Jürgen Hötzel <address@hidden>
* net/tramp.el (tramp-eshell-directory-change): Check remote-path
=== modified file 'lisp/doc-view.el'
--- a/lisp/doc-view.el 2013-01-04 02:45:59 +0000
+++ b/lisp/doc-view.el 2013-01-09 19:48:42 +0000
@@ -158,6 +158,30 @@
:type 'file
:group 'doc-view)
+(defcustom doc-view-pdfdraw-program "mudraw"
+ "Program to convert PDF files to PNG."
+ :type 'file
+ :version "24.4")
+
+(defcustom doc-view-pdf->png-converter-function
+ 'doc-view-pdf->png-converter-ghostscript
+ "Function to call to convert a PDF file into a PNG file."
+ :type '(radio
+ (function-item doc-view-pdf->png-converter-ghostscript
+ :doc "Use ghostscript")
+ (function-item doc-view-pdf->png-converter-mupdf
+ :doc "Use mupdf")
+ function)
+ :version "24.4")
+
+(defcustom doc-view-ps->png-converter-function
+ 'doc-view-ps->png-converter-ghostscript
+ "Function to call to convert a PS file into a PNG file."
+ :type '(radio (function-item doc-view-ps->png-converter-ghostscript
+ :doc "Use ghostscript")
+ function)
+ :version "24.4")
+
(defcustom doc-view-ghostscript-options
'("-dSAFER" ;; Avoid security problems when rendering files from untrusted
;; sources.
@@ -661,6 +685,7 @@
(executable-find doc-view-dvipdfm-program)))))
((or (eq type 'postscript) (eq type 'ps) (eq type 'eps)
(eq type 'pdf))
+ ;; FIXME: allow mupdf here
(and doc-view-ghostscript-program
(executable-find doc-view-ghostscript-program)))
((eq type 'odf)
@@ -826,6 +851,25 @@
(list "-o" pdf dvi)
callback)))
+(defun doc-view-pdf->png-converter-ghostscript (resolution pdf png &optional
page)
+ `((command . ,doc-view-ghostscript-program)
+ (arguments . (,@doc-view-ghostscript-options
+ ,(format "-r%d" resolution)
+ ,@(if page `(,(format "-dFirstPage=%d" page)))
+ ,@(if page `(,(format "-dLastPage=%d" page)))
+ ,(concat "-sOutputFile=" png)
+ ,pdf))))
+
+(defalias 'doc-view-ps->png-converter-ghostscript
+ 'doc-view-pdf->png-converter-ghostscript)
+
+(defun doc-view-pdf->png-converter-mupdf (resolution pdf png &optional page)
+ `((command . ,doc-view-pdfdraw-program)
+ (arguments . (,(concat "-o" png)
+ ,(format "-r%d" resolution)
+ ,pdf
+ ,@(if page `(,(format "%d" page)))))))
+
(defun doc-view-odf->pdf (odf callback)
"Convert ODF to PDF asynchronously and call CALLBACK when finished.
The converted PDF is put into the current cache directory, and it
@@ -836,12 +880,15 @@
(defun doc-view-pdf/ps->png (pdf-ps png)
"Convert PDF-PS to PNG asynchronously."
- (doc-view-start-process
- "pdf/ps->png" doc-view-ghostscript-program
- (append doc-view-ghostscript-options
- (list (format "-r%d" (round doc-view-resolution))
- (concat "-sOutputFile=" png)
- pdf-ps))
+ (let ((invocation
+ (pcase doc-view-doc-type
+ (`pdf (funcall doc-view-pdf->png-converter-function
+ (round doc-view-resolution) pdf-ps png))
+ (_ (funcall doc-view-ps->png-converter-function
+ (round doc-view-resolution) pdf-ps png)))))
+ (doc-view-start-process
+ "pdf/ps->png" (cdr (assoc 'command invocation))
+ (cdr (assoc 'arguments invocation))
(let ((resolution doc-view-resolution))
(lambda ()
;; Only create the resolution file when it's all done, so it also
@@ -853,7 +900,7 @@
(when doc-view-current-timer
(cancel-timer doc-view-current-timer)
(setq doc-view-current-timer nil))
- (doc-view-display (current-buffer) 'force))))
+ (doc-view-display (current-buffer) 'force)))))
;; Update the displayed pages as soon as they're done generating.
(when doc-view-conversion-refresh-interval
(setq doc-view-current-timer
@@ -864,17 +911,12 @@
(defun doc-view-pdf->png-1 (pdf png page callback)
"Convert a PAGE of a PDF file to PNG asynchronously.
Call CALLBACK with no arguments when done."
- (doc-view-start-process
- "pdf->png-1" doc-view-ghostscript-program
- (append doc-view-ghostscript-options
- (list (format "-r%d" (round doc-view-resolution))
- ;; Sadly, `gs' only supports the page-range
- ;; for PDF files.
- (format "-dFirstPage=%d" page)
- (format "-dLastPage=%d" page)
- (concat "-sOutputFile=" png)
- pdf))
- callback))
+ (let ((invocation (funcall doc-view-pdf->png-converter-function
+ (round doc-view-resolution) pdf png page)))
+ (doc-view-start-process
+ "pdf/ps->png" (cdr (assoc 'command invocation))
+ (cdr (assoc 'arguments invocation))
+ callback)))
(declare-function clear-image-cache "image.c" (&optional filter))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r111462: * lisp/doc-view.el: Add support for mupdf converter.,
Stefan Monnier <=