"Eric Schulte" <schulte.e...@gmail.com> writes:

>> The only thing missing is a function to export all (not excluded)
>> subtrees one by one and honor the properties slapped onto each subtree.
>>
>
> `org-map-entries' should satisfy this need. -- Eric

I have been doing something similar with LaTeX export.  Here is my
(pretty hacky) code; it should be easy to adapt to HTML export.  It
does the following:

1) export each subtree of the current tree as a separate PDF (there's
some validation here, to make sure each of these trees has properties
that I need to produce the output I want)

2) concatenates the resulting PDFs into a single PDF for printing (this
requires the pdftk package)

Good luck!

Richard

;;;;
(defun org-export-individual-pdfs-and-concat ()
  (interactive)
  (setq export-files nil
        pdf-files nil
        ; point must be in main tree to be exported (not a subtree)
        concat-pdf-name (get-property-or-fail (point) "CONCATENATED_PDF_NAME"))
  (progn
    (org-map-entries
     (lambda ()
       (setq org-map-continue-from (outline-next-heading))
       (org-mark-subtree)
       ; org-map-entries positions point at the beginning of each subtree
       (let ((org-trust-scanner-tags t))
         (push (get-property-or-fail (point) "EXPORT_FILE_NAME") export-files))
       (org-export-as-pdf nil))
     nil 'tree)
    (concat-pdfs (nreverse (mapcar 'tex-name-to-pdf-name export-files))
                 concat-pdf-name)))

(defun get-property-or-fail (pom property)
  (or
   ; probably some opportunity for optimization here...see function
   ; documentation for org-map-entries
   (org-entry-get pom property)
   (error (format "Entry at %s does not define property %s" 
(org-heading-components) property))))

(defun tex-name-to-pdf-name (filename)
  (concat (file-name-sans-extension filename) ".pdf"))

(defun concat-pdfs (in-files out-file)
  (shell-command
   (format "pdftk %s cat output %s"
           (mapconcat (lambda (s) s) in-files " ") ; join pdf names with spaces
           out-file))) 


_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

Reply via email to