Permalink
Browse files

call the "org-file-to-pdf" emacs function from acts_as_org.rb

  • Loading branch information...
1 parent 9f90d66 commit fdca7a2ddccd55fb461f330a53e4aa02fc4df1cc Francesco Pizzolante committed with Nov 23, 2009
Showing with 31 additions and 0 deletions.
  1. +31 −0 lib/acts_as_org.rb
View
@@ -80,6 +80,24 @@ def clean_latex?(path)
l_path = self.latex_path(path)
File.exist?(l_path) and File.mtime(l_path) > File.mtime(path)
end
+
+ def pdf_path(path)
+ File.join(File.dirname(path),
+ ActiveFile::Acts::Org::EXP_PREFIX + File.basename(path) + ".pdf")
+ end
+
+ def to_pdf(path, options = {})
+ p_path = self.pdf_path(path)
+ options = {:postamble => false}.merge(options)
+ self.emacs_run("(org-file-to-pdf \"#{path}\")") unless self.clean_pdf?(path)
+ return nil unless File.exist?(p_path)
+ html = File.read(p_path)
+ end
+
+ def clean_pdf?(path)
+ p_path = self.pdf_path(path)
+ File.exist?(p_path) and File.mtime(p_path) > File.mtime(path)
+ end
end
module InstanceMethods
@@ -107,6 +125,19 @@ def to_latex(options = {})
self.class.to_latex(self.full_path, options)
end
alias :to_tex :to_latex
+
+ def pdf_path
+ self.class.pdf_path(self.full_path)
+ end
+
+ def clean_pdf?
+ self.class.clean_pdf?(self.full_path)
+ end
+
+ def to_pdf(options = {})
+ self.class.to_pdf(self.full_path, options)
+ end
+
end
end
end

0 comments on commit fdca7a2

Please sign in to comment.