pdf_gem 1.0.3 → 1.0.7
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.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/lib/pdf_gem/version.rb +1 -1
- data/lib/pdf_gem.rb +1 -1
- data/lib/renderer.rb +1 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4c0bda6a2f0b4e18cd46e48244daa04dc915aadd3e97fc4c610693dd6a50ad7
|
4
|
+
data.tar.gz: c3c291cb440ef39d1594485d7cb826df23fc14e60c132c3285561a209868c58b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fad7f3dd35e1627f48bd11a45705eb8b8b21439d0d1e1795a83530cb0ef0e45c4ca0a8fdc2cf0da8f5f3c1e0485e28c8880d739126cf059d18d0624512e7672
|
7
|
+
data.tar.gz: 9bc66a23cfcb9ccd9bede74f8f0d63988fc37d8721a90a73fbf37f484a6c127dcf892602c8d09f4aa00f5ab3feb8bc19c817b8c071fd7dab9588970d726838cc
|
data/README.md
CHANGED
@@ -25,6 +25,15 @@ Or install it yourself as:
|
|
25
25
|
$ gem install pdf_gem
|
26
26
|
```
|
27
27
|
|
28
|
+
Add this lines to `application.rb`
|
29
|
+
```ruby
|
30
|
+
ActionController::Renderers.add :pdf do |template, options|
|
31
|
+
PdfGem.renderer(template, options)
|
32
|
+
end
|
33
|
+
```
|
34
|
+
> **NOTE** You can change the :pdf in some other name if you have conflicts with other similar libraries
|
35
|
+
|
36
|
+
|
28
37
|
You may need to add
|
29
38
|
```ruby
|
30
39
|
Mime::Type.register "application/pdf", :pdf
|
data/lib/pdf_gem/version.rb
CHANGED
data/lib/pdf_gem.rb
CHANGED
data/lib/renderer.rb
CHANGED
@@ -1,16 +1,10 @@
|
|
1
1
|
module PdfGem
|
2
|
-
|
2
|
+
def self.renderer(template, options)
|
3
3
|
params = options.except(:prefixes, :template, :disposition, :url, :html, :filename, :formats)
|
4
4
|
params[:html] = render_to_string(:action => (template.present? ? template : options.template), formats: options[:formats].present? ? options[:formats] : [:pdf] )
|
5
5
|
send_data PdfGem::pdf_from_string(params), type: Mime[:pdf], disposition: (params[:disposition].present? ? params[:disposition] : 'inline'), :filename => options[:filename]
|
6
6
|
end
|
7
7
|
|
8
|
-
ActionController::Renderers.add :pdf2 do |template, options|
|
9
|
-
params = options.except(:prefixes, :template, :disposition, :url, :html, :filename, :formats)
|
10
|
-
params[:html] = render_to_string(:action => (template.present? ? template : options.template), formats: options[:formats].present? ? options[:formats] : [:pdf] )
|
11
|
-
send_data PdfGem::pdf_from_string(params), type: Mime[:pdf], disposition: (params[:disposition].present? ? params[:disposition] : 'inline'), :filename => options[:filename]
|
12
|
-
end
|
13
|
-
|
14
8
|
if Mime::Type.lookup_by_extension(:pdf).nil?
|
15
9
|
Mime::Type.register('application/pdf', :pdf)
|
16
10
|
end
|