Class: ActsAsFlyingSaucer::Xhtml2Pdf
- Inherits:
-
Object
- Object
- ActsAsFlyingSaucer::Xhtml2Pdf
- Defined in:
- lib/acts_as_flying_saucer/xhtml2pdf.rb
Overview
Xhtml2Pdf
Class Method Summary collapse
Class Method Details
.encrypt_pdf(options, output_file_name, password) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/acts_as_flying_saucer/xhtml2pdf.rb', line 29 def self.encrypt_pdf(,output_file_name,password) java_dir = File.join(File.(File.dirname(__FILE__)), "java") class_path = "'.#{options[:classpath_separator]}#{java_dir}/jar/acts_as_flying_saucer.jar'" if [:nailgun] command = "#{Nailgun::NgCommand::NGPATH} --nailgun-server #{ActsAsFlyingSaucer::Config.options[:nailgun_host]} --nailgun-port #{ ActsAsFlyingSaucer::Config.options[:nailgun_port]} encryptPdf #{options[:input_file]} #{options[:output_file]}" else command = "#{options[:java_bin]} -Xmx#{options[:max_memory_mb]}m -Djava.awt.headless=true -cp #{class_path} acts_as_flying_saucer.encryptPdf #{options[:output_file]} #{output_file_name} #{password}" end system(command) end |
.write_pdf(options) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/acts_as_flying_saucer/xhtml2pdf.rb', line 7 def self.write_pdf() if !File.exists?([:input_file]) File.open([:input_file], 'w') do |file| file << [:html] end end class_path = "" java_dir = File.join(File.(File.dirname(__FILE__)), "java") Dir.glob("#{java_dir}/jar/*.jar") do |jar| class_path << "#{options[:classpath_separator]}#{jar}" end if [:nailgun] command = "#{Nailgun::NgCommand::NGPATH} --nailgun-server #{ActsAsFlyingSaucer::Config.options[:nailgun_host]} --nailgun-port #{ ActsAsFlyingSaucer::Config.options[:nailgun_port]} Xhtml2Pdf #{options[:input_file]} #{options[:output_file]}" else command = "#{options[:java_bin]} -Xmx#{options[:max_memory_mb]}m -Djava.awt.headless=true -cp #{class_path} acts_as_flying_saucer.Xhtml2Pdf #{options[:input_file]} #{options[:output_file]}" end system(command) end |