ferrum_pdf 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +43 -12
- data/lib/ferrum_pdf/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ea0c6aba4254ef7d958dec7d9f51048ce82e106ab068a413c1e3b83ec470b01
|
4
|
+
data.tar.gz: e34df1014f457e4ad42a41a5a29ab9a0d0ab42027cb8d8374aeacf6557a49833
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68e840f65f0c0821cb8dfe6f3e249e2b5b567f8d3655c1a71a59f143beb25241aedea29fe33d95b18763a32fd5eea88bec9f6a9f4b0b6181df082544cc2453c2
|
7
|
+
data.tar.gz: 123f094697e37dcee391c157ca5ba379b1b9557e8a4e7c017cb7b45861936bf24e484bec74092793dd3e64e36ffaee0a98bc613f56ed9a5e4e2dfefdbf7f1ac1
|
data/README.md
CHANGED
@@ -1,28 +1,59 @@
|
|
1
1
|
# FerrumPdf
|
2
|
-
Short description and motivation.
|
3
2
|
|
4
|
-
|
5
|
-
How to use my plugin.
|
3
|
+
PDFs for Rails using [Ferrum](https://github.com/rubycdp/ferrum) & headless Chrome
|
6
4
|
|
7
5
|
## Installation
|
8
|
-
|
6
|
+
|
7
|
+
Run the following or add the gem to your Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
bundle add "ferrum_pdf"
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
### Rails controllers
|
16
|
+
|
17
|
+
Use the `render_pdf` helper in Rails controllers to render a PDF from the current action.
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
def show
|
21
|
+
respond_to do |format|
|
22
|
+
format.html
|
23
|
+
format.pdf { send_data render_pdf, disposition: :inline, filename: "example.pdf" }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
You can also customize which template is rendered:
|
9
29
|
|
10
30
|
```ruby
|
11
|
-
|
31
|
+
render_pdf(name = action_name, formats: [ :html ])
|
12
32
|
```
|
13
33
|
|
14
|
-
|
15
|
-
|
16
|
-
|
34
|
+
This will render the template to string, then pass it along to FerrumPdf.
|
35
|
+
|
36
|
+
### Directly with HTML
|
37
|
+
|
38
|
+
FerrumPdf can generate a PDF from HTML directly:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
FerrumPdf.render_pdf(html: content)
|
17
42
|
```
|
18
43
|
|
19
|
-
|
20
|
-
|
21
|
-
|
44
|
+
You can also pass host and protocol to convert any relative paths to full URLs. This is helpful for converting relative asset paths to full URLs.
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
FerrumPdf.render_pdf(
|
48
|
+
html: content,
|
49
|
+
host: request.host_with_port,
|
50
|
+
protocol: request.protocol
|
51
|
+
)
|
22
52
|
```
|
23
53
|
|
24
54
|
## Contributing
|
25
|
-
|
55
|
+
|
56
|
+
If you have an issue you'd like to submit, please do so using the issue tracker in GitHub. In order for us to help you in the best way possible, please be as detailed as you can.
|
26
57
|
|
27
58
|
## License
|
28
59
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/ferrum_pdf/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ferrum_pdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Oliver
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 6.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 6.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: ferrum
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|