ovni 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
@@ -0,0 +1,19 @@
1
+ module OVNI
2
+ class Config
3
+ # default options
4
+ @@options = { :max_memory_mb => 64,
5
+ :java_bin => "java",
6
+ :classpath_separator => ':',
7
+ :class_path => ["bouncy_castle/bcprov-jdk16-136.jar", "flying_saucer/core-renderer.jar", "itext/iText-2.0.8.jar"].collect{|n| File.join(File.expand_path(File.dirname(__FILE__)), n)}
8
+ }
9
+
10
+ if respond_to?(:cattr_accessor)
11
+ cattr_accessor :options
12
+ else
13
+ def self.options
14
+ @@options
15
+ end
16
+ end
17
+ end
18
+
19
+ end
Binary file
@@ -0,0 +1,3 @@
1
+ module OVNI
2
+ VERSION = "0.0.1"
3
+ end
data/lib/ovni.rb ADDED
@@ -0,0 +1,23 @@
1
+ require 'tempfile'
2
+
3
+ ovni_path = File.expand_path('../ovni/', __FILE__)
4
+
5
+ require "#{ovni_path}/version"
6
+ require "#{ovni_path}/config"
7
+
8
+ module OVNI
9
+ def self.html_to_pdf(html, pdf_file, options = {})
10
+ options = Config.options.merge(options)
11
+
12
+ class_path = [File.join(File.expand_path(File.dirname(__FILE__)), "ovni/Xhtml2Pdf"), options[:class_path]].join(options[:classpath_separator])
13
+
14
+ Tempfile.open("ovni") do |file|
15
+ file << html
16
+ file.flush
17
+
18
+ command = "#{options[:java_bin]} -Xmx#{options[:max_memory_mb]}m -Djava.awt.headless=true -cp #{class_path} Xhtml2Pdf #{file.path} #{File.expand_path(pdf_file)}"
19
+
20
+ system(command)
21
+ end
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ovni
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Henning Kiel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-04-27 00:00:00 +02:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Simple wrapper helping to use the Flying Saucer Java library to convert HTML to PDF
17
+ email:
18
+ - henning.kiel@gmail.com
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files: []
24
+
25
+ files:
26
+ - lib/ovni.rb
27
+ - lib/ovni/bouncy_castle/bcprov-jdk16-136.jar
28
+ - lib/ovni/version.rb
29
+ - lib/ovni/config.rb
30
+ - lib/ovni/flying_saucer/core-renderer.jar
31
+ - lib/ovni/itext/iText-2.0.8.jar
32
+ - lib/ovni/Xhtml2Pdf/Xhtml2Pdf.class
33
+ has_rdoc: true
34
+ homepage: http://github.com/hennk/ovni
35
+ licenses: []
36
+
37
+ post_install_message:
38
+ rdoc_options: []
39
+
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ version:
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 1.3.5
53
+ version:
54
+ requirements: []
55
+
56
+ rubyforge_project: ovni
57
+ rubygems_version: 1.3.5
58
+ signing_key:
59
+ specification_version: 3
60
+ summary: Simple wrapper for the Flying Saucer Java library
61
+ test_files: []
62
+