浏览代码

Agenda export: Implement PDF export

The agenda can ow also be written to a pdf file.  This requires the
ps2pdf utility to be present on the system.
Carsten Dominik 16 年之前
父节点
当前提交
f4d1d56046
共有 3 个文件被更改,包括 27 次插入10 次删除
  1. 13 8
      doc/org.texi
  2. 1 0
      lisp/ChangeLog
  3. 13 2
      lisp/org-agenda.el

+ 13 - 8
doc/org.texi

@@ -6805,12 +6805,12 @@ This is a globally available command, and also available in the agenda menu.
 @cindex exporting agenda views
 @cindex agenda views, exporting
 @vindex org-agenda-exporter-settings
-Write the agenda view to a file.  Depending on the extension of the
-selected file name, the view will be exported as HTML (extension
-@file{.html} or @file{.htm}), Postscript (extension @file{.ps}), or
-plain text (any other extension).  Use the variable
-@code{org-agenda-exporter-settings} to set options for @file{ps-print}
-and for @file{htmlize} to be used during export.
+Write the agenda view to a file.  Depending on the extension of the selected
+file name, the view will be exported as HTML (extension @file{.html} or
+@file{.htm}), Postscript (extension @file{.ps}), PDF
+(extension @file{.pdf}), or plain text (any other extension).  Use the
+variable @code{org-agenda-exporter-settings} to set options for
+@file{ps-print} and for @file{htmlize} to be used during export.
 
 @tsubheading{Quit and Exit}
 @kindex q
@@ -7025,8 +7025,10 @@ yourself.
 If you are away from your computer, it can be very useful to have a printed
 version of some agenda views to carry around.  Org mode can export custom
 agenda views as plain text, HTML@footnote{You need to install Hrvoje Niksic's
-@file{htmlize.el}.}, Postscript, and iCalendar files.  If you want to do this
-only occasionally, use the command
+@file{htmlize.el}.}, Postscript, PDF@footnote{To create PDF output, the
+ghostscript @file{ps2pdf} utility must be installed on the system.  Selecting
+a pdf file with also create the postscript file.}, and iCalendar files.  If
+you want to do this only occasionally, use the command
 
 @table @kbd
 @kindex C-x C-w
@@ -7046,6 +7048,9 @@ export, for example
 (setq org-agenda-exporter-settings
       '((ps-number-of-columns 2)
         (ps-landscape-mode t)
+        (org-agenda-before-write-hook
+            '(org-agenda-add-entry-text))
+        (org-agenda-add-entry-text-maxlines 5)
         (htmlize-output-type 'css)))
 @end lisp
 @end table

+ 1 - 0
lisp/ChangeLog

@@ -4,6 +4,7 @@
 	(org-agenda-add-entry-text-maxlines): New options.
 	(org-write-agenda): Run the new hook in the temporary buffer.
 	(org-agenda-add-entry-text): New function.
+	(org-write-agenda): Implement PDF export, using ps2pdf.
 
 	* org.el (org-global-properties-fixed, org-global-properties):
 	Improve documentation string.

+ 13 - 2
lisp/org-agenda.el

@@ -2025,8 +2025,20 @@ higher priority settings."
 	       (kill-buffer (current-buffer))
 	       (message "HTML written to %s" file))
 	      ((string-match "\\.ps\\'" file)
-	       (ps-print-buffer-with-faces file)
+	       (require 'ps-print)
+	       (flet ((ps-get-buffer-name () "Agenda View"))
+		 (ps-print-buffer-with-faces file))
 	       (message "Postscript written to %s" file))
+	      ((string-match "\\.pdf\\'" file)
+	       (require 'ps-print)
+	       (flet ((ps-get-buffer-name () "Agenda View"))
+		 (ps-print-buffer-with-faces
+		  (concat (file-name-sans-extension file) ".ps")))
+	       (call-process "ps2pdf" nil nil nil
+			     (expand-file-name
+			      (concat (file-name-sans-extension file) ".ps"))
+			     (expand-file-name file))
+	       (message "PDF written to %s" file))
 	      ((string-match "\\.ics\\'" file)
 	       (let ((org-agenda-marker-table
 		      (org-create-marker-find-array
@@ -5997,4 +6009,3 @@ belonging to the \"Work\" category."
 ;; arch-tag: 77f7565d-7c4b-44af-a2df-9f6f7070cff1
 
 ;;; org-agenda.el ends here
-