wicked_pdf 0.7.8 → 0.7.9

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.
data/README.md CHANGED
@@ -44,6 +44,7 @@ or add this to your Gemfile:
44
44
  format.html
45
45
  format.pdf do
46
46
  render :pdf => 'file_name',
47
+ :disposition => 'attachment', # default 'inline'
47
48
  :template => 'things/show.pdf.erb',
48
49
  :layout => 'pdf.html', # use 'pdf.html' for a pdf.html.erb file
49
50
  :wkhtmltopdf => '/usr/local/bin/wkhtmltopdf', # path to binary
@@ -92,7 +93,8 @@ or add this to your Gemfile:
92
93
  :left => 'TEXT',
93
94
  :right => 'TEXT',
94
95
  :spacing => REAL,
95
- :line => true},
96
+ :line => true,
97
+ :content => 'HTML CONTENT ALREADY RENDERED'}, # optionally you can pass plain html already rendered (useful if using pdf_from_string)
96
98
  :footer => {:html => { :template => 'shared/footer.pdf.erb', # use :template OR :url
97
99
  :layout => 'pdf_plain.html', # optional, use 'pdf_plain.html' for a pdf_plain.html.erb file, defaults to main layout
98
100
  :url => 'www.example.com',
@@ -103,7 +105,8 @@ or add this to your Gemfile:
103
105
  :left => 'TEXT',
104
106
  :right => 'TEXT',
105
107
  :spacing => REAL,
106
- :line => true},
108
+ :line => true,
109
+ :content => 'HTML CONTENT ALREADY RENDERED'}, # optionally you can pass plain html already rendered (useful if using pdf_from_string)
107
110
  :toc => {:font_name => "NAME",
108
111
  :depth => LEVEL,
109
112
  :header_text => "TEXT",
@@ -140,6 +143,11 @@ If you need to just create a pdf and not display it:
140
143
 
141
144
  # create a pdf from a string
142
145
  pdf = WickedPdf.new.pdf_from_string('<h1>Hello There!</h1>')
146
+
147
+ # create a pdf from string using templates, layouts and content option for header or footer
148
+ WickedPdf.new.pdf_from_string(
149
+ render_to_string(:pdf => "pdf_file.pdf", :template => 'templates/pdf.html.erb', :layout => 'pdfs/layout_pdf'),
150
+ :footer => {:content => render_to_string({:template => 'templates/pdf_footer.html.erb', :layout => 'pdfs/layout_pdf'})}
143
151
 
144
152
  # or from your controller, using views & templates and all wicked_pdf options as normal
145
153
  pdf = render_to_string :pdf => "some_file_name"
data/lib/wicked_pdf.rb CHANGED
@@ -107,6 +107,15 @@ class WickedPdf
107
107
  r += make_options(opt_hf, [:center, :font_name, :left, :right], "#{hf.to_s}")
108
108
  r += make_options(opt_hf, [:font_size, :spacing], "#{hf.to_s}", :numeric)
109
109
  r += make_options(opt_hf, [:line], "#{hf.to_s}", :boolean)
110
+ if options[hf] && options[hf][:content]
111
+ @hf_tempfiles = [] if ! defined?(@hf_tempfiles)
112
+ @hf_tempfiles.push( tf=WickedPdfTempfile.new("wicked_#{hf}_pdf.html") )
113
+ tf.write options[hf][:content]
114
+ tf.flush
115
+ options[hf].delete(:content)
116
+ options[hf][:html] = {}
117
+ options[hf][:html][:url] = "file://#{tf.path}"
118
+ end
110
119
  unless opt_hf[:html].blank?
111
120
  r += make_option("#{hf.to_s}-html", opt_hf[:html][:url]) unless opt_hf[:html][:url].blank?
112
121
  end
@@ -175,7 +184,7 @@ class WickedPdf
175
184
  r +=make_options(options, [ :book,
176
185
  :default_header,
177
186
  :disable_javascript,
178
- :greyscale,
187
+ :grayscale,
179
188
  :lowquality,
180
189
  :enable_plugins,
181
190
  :disable_internal_links,
@@ -137,7 +137,7 @@ class WickedPdfTest < ActiveSupport::TestCase
137
137
  assert_equal "--#{o.to_s.gsub('_', '-')} 5", wp.get_parsed_options(o => 5).strip
138
138
  end
139
139
 
140
- [ :book, :default_header, :disable_javascript, :greyscale, :lowquality,
140
+ [ :book, :default_header, :disable_javascript, :grayscale, :lowquality,
141
141
  :enable_plugins, :disable_internal_links, :disable_external_links,
142
142
  :print_media_type, :disable_smart_shrinking, :use_xserver, :no_background
143
143
  ].each do |o|
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wicked_pdf
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 8
10
- version: 0.7.8
9
+ - 9
10
+ version: 0.7.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Miles Z. Sterret
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-23 00:00:00 Z
18
+ date: 2012-04-30 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: |