acts_as_flying_saucer 0.0.9 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown
CHANGED
@@ -45,6 +45,8 @@ It accepts the same options as ActionController::Base#render plus the following
|
|
45
45
|
:clean - (boolean expected) It cleans up html using tidy (It uses tidy_ffi gem) default is false
|
46
46
|
|
47
47
|
:send_to_client - (boolean expected) If it is false it returns output pdf and attachment is not sent to client.
|
48
|
+
|
49
|
+
:url - url can be file path or any http url (with http or https) or string. This will generated pdf from file,url or string.
|
48
50
|
|
49
51
|
class FooController < ActionController::Base
|
50
52
|
acts_as_flying_saucer
|
@@ -115,12 +117,15 @@ Sinatra
|
|
115
117
|
Ruby
|
116
118
|
----
|
117
119
|
class Pdf
|
118
|
-
|
119
|
-
|
120
|
-
|
120
|
+
include ActsAsFlyingSaucer::Controller
|
121
|
+
acts_as_flying_saucer
|
122
|
+
def generate_pdf(input_file_html_or_string,output_pdf)
|
123
|
+
options = ActsAsFlyingSaucer::Config.options.merge({:url=>input_file_html_or_string,:pdf_file=>output_pdf})
|
124
|
+
render_pdf(options)
|
121
125
|
end
|
122
126
|
end
|
123
127
|
|
128
|
+
|
124
129
|
Configuration
|
125
130
|
-------------
|
126
131
|
|
@@ -3,6 +3,8 @@ require 'acts_as_flying_saucer/xhtml2pdf'
|
|
3
3
|
require 'acts_as_flying_saucer/acts_as_flying_saucer_controller'
|
4
4
|
require 'nailgun'
|
5
5
|
require 'tidy_ffi'
|
6
|
+
require 'net/http'
|
7
|
+
require 'uri'
|
6
8
|
if defined?(Rails)
|
7
9
|
ActionController::Base.send(:include, ActsAsFlyingSaucer::Controller)
|
8
10
|
elsif defined?(Sinatra)
|
@@ -29,14 +29,18 @@ module ActsAsFlyingSaucer
|
|
29
29
|
# render_pdf
|
30
30
|
#
|
31
31
|
def render_pdf(options = {})
|
32
|
-
|
33
|
-
# host = ActionController::Base.asset_host
|
34
|
-
# ActionController::Base.asset_host = request.protocol + request.host_with_port if host.blank?
|
35
|
-
#
|
36
|
-
# logger.debug("#{host} - #{host.nil?} - #{ActionController::Base.asset_host}")
|
37
|
-
tidy_clean = options[:clean] || false
|
32
|
+
tidy_clean = options[:clean] || false
|
38
33
|
self.pdf_mode = :create
|
39
|
-
|
34
|
+
if options[:url]
|
35
|
+
tidy_clean = true
|
36
|
+
if options[:url].match(/\Ahttp/)
|
37
|
+
html = Net::HTTP.get_response(URI.parse(options[:url])).body rescue options[:url]
|
38
|
+
elsif File.exist?(options[:url])
|
39
|
+
html = File.read(options[:url]) rescue ""
|
40
|
+
else
|
41
|
+
html = options[:url]
|
42
|
+
end
|
43
|
+
elsif defined?(Rails)
|
40
44
|
host = ActionController::Base.asset_host
|
41
45
|
ActionController::Base.asset_host = request.protocol + request.host_with_port if host.blank?
|
42
46
|
html = render_to_string options
|
@@ -55,7 +59,7 @@ module ActsAsFlyingSaucer
|
|
55
59
|
end
|
56
60
|
# saving the file
|
57
61
|
tmp_dir = ActsAsFlyingSaucer::Config.options[:tmp_path]
|
58
|
-
html = TidyFFI::Tidy.new(html).clean if tidy_clean
|
62
|
+
html = TidyFFI::Tidy.new(html,:output_xhtml=>true).clean if tidy_clean
|
59
63
|
html_digest = Digest::MD5.hexdigest(html)
|
60
64
|
input_file =File.join(File.expand_path("#{tmp_dir}"),"#{html_digest}.html")
|
61
65
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_flying_saucer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
|
+
- 1
|
7
8
|
- 0
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.9
|
10
|
+
version: 1.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Amar Daxini
|
@@ -15,7 +15,8 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-10-
|
18
|
+
date: 2011-10-31 00:00:00 +05:30
|
19
|
+
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: nailgun
|
@@ -68,6 +69,7 @@ files:
|
|
68
69
|
- lib/acts_as_flying_saucer/java/src/encryptPdf.java
|
69
70
|
- lib/acts_as_flying_saucer/version.rb
|
70
71
|
- lib/acts_as_flying_saucer/xhtml2pdf.rb
|
72
|
+
has_rdoc: true
|
71
73
|
homepage: http://rubygems.org/gems/acts_as_flying_saucer
|
72
74
|
licenses: []
|
73
75
|
|
@@ -97,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
99
|
requirements: []
|
98
100
|
|
99
101
|
rubyforge_project: acts_as_flying_saucer
|
100
|
-
rubygems_version: 1.
|
102
|
+
rubygems_version: 1.4.2
|
101
103
|
signing_key:
|
102
104
|
specification_version: 3
|
103
105
|
summary: XHTML to PDF using Flying Saucer java library
|