rails_pdf 0.1.2 → 0.1.3
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 +45 -8
- data/lib/rails_pdf/version.rb +2 -2
- 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: ff4ea451dd985532dd06ad6f39077f72d2548f079e7a6b08137d9188af7d6093
|
4
|
+
data.tar.gz: c5e975d26cbd6325574ddb882f28d123abb2805f2da34c9426d1632427298fbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea72f4697bd60be620899bcd99918563d6fcb88d1ba3c715907e74745d0ef6aeff4e6715e16d8c978cb304eecdef22eff98a5a88de5208bdfd4893eb4f6a8f6f
|
7
|
+
data.tar.gz: dc7dff507f0cc393f73a85b712f0c750ceb06211d55157ee60005100f9633c30c45112d9b8d976d35e6ae8425c54bec24dfc16373d34e6e64a7f4ee165093e3f
|
data/README.md
CHANGED
@@ -1,11 +1,23 @@
|
|
1
1
|
# RailsPDF
|
2
2
|
|
3
|
-
Create PDF
|
3
|
+
Create PDF documents in Rails your app from HTML, CSS and JS.
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
-
|
8
|
-
-
|
5
|
+
**Features:**
|
6
|
+
|
7
|
+
- Basically, you can create any HTML/CSS/JS/Images page and save into PDF
|
8
|
+
- Generate PDF on the fly or save to disk
|
9
|
+
- With header, footer, page numbers, layout support
|
10
|
+
- Has few starter templates to help with most popular reports. Just create some and re-edit it
|
11
|
+
- Support for Charts libraries
|
12
|
+
- ERB/SCSS support
|
13
|
+
- Custome & Google fonts
|
14
|
+
- Separates PDF templates from app views
|
15
|
+
- Doesn't insert any middleware into your app
|
16
|
+
- Pub format is similar to slim
|
17
|
+
|
18
|
+
It's uses [ReLaXedJS](https://github.com/RelaxedJS/ReLaXed) tool, which is wrapper arround chromium headless.
|
19
|
+
|
20
|
+
The idea of this gem is to separate logic of PDF creation from regular Rails views/controllers. Make it independent and easy to maintain.
|
9
21
|
|
10
22
|
## Template starters
|
11
23
|
|
@@ -51,21 +63,37 @@ You can use JS/CSS files from `app/pdf/shared` (which includes bootstrap 4, foun
|
|
51
63
|
|
52
64
|
This is how you can generate and send PDF files on the fly:
|
53
65
|
|
54
|
-
```
|
66
|
+
```ruby
|
55
67
|
def report
|
56
68
|
RailsPDF.template("report2/invoice.pug.erb").render do |data|
|
57
69
|
send_data(data, type: 'application/pdf', disposition: 'inline', filename: 'report.pdf')
|
58
70
|
end
|
59
71
|
end
|
72
|
+
|
73
|
+
# or return file as attachment
|
74
|
+
|
75
|
+
def invoice
|
76
|
+
RailsPDF.template("report2/invoice.pug.erb").render do |data|
|
77
|
+
send_data(data, type: 'application/pdf', disposition: 'attachment', filename: 'report.pdf')
|
78
|
+
end
|
79
|
+
end
|
60
80
|
```
|
61
81
|
|
62
82
|
If you need to create PDF file and save to file on drive:
|
63
83
|
|
64
|
-
|
84
|
+
```ruby
|
85
|
+
RailsPDF.template("report/chart.pug.erb").render_to_file('path/docs/report.pdf') # File
|
86
|
+
|
87
|
+
# or for html template
|
88
|
+
|
89
|
+
RailsPDF.template("sales/invoice.html.erb").render_to_file('path/docs/report.pdf') # File
|
90
|
+
```
|
65
91
|
|
66
92
|
Same but save PDF into Temfile:
|
67
93
|
|
68
|
-
|
94
|
+
```ruby
|
95
|
+
RailsPDF.template("report/chart.pug.erb").render_to_tempfile('report.pdf') # Tempfile
|
96
|
+
```
|
69
97
|
|
70
98
|
With ERB files you can use App code (like models, etc). For example you can iterate over @users and output in PDF.
|
71
99
|
|
@@ -145,8 +173,17 @@ $ bundle
|
|
145
173
|
## TODO
|
146
174
|
|
147
175
|
- more starter templates
|
176
|
+
- add starter template with page numbers
|
148
177
|
- add different charts
|
149
178
|
- better way to include JS/CSS/images
|
179
|
+
- maybe we don't need to include all views
|
180
|
+
- support non-rails apps
|
181
|
+
- specs
|
182
|
+
- travis CI
|
183
|
+
- codeclimate
|
184
|
+
- check support for older Rails (should work but check is needed)
|
185
|
+
- check embedding in emails
|
186
|
+
- maybe add ability to save webpage by url or HTML snippet to PDF, e.g. `RailsPDF.url("http://google.com").render_to_file("google.com.pdf")`
|
150
187
|
|
151
188
|
## Production
|
152
189
|
|
data/lib/rails_pdf/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module RailsPDF
|
2
|
-
VERSION = '0.1.
|
3
|
-
end
|
2
|
+
VERSION = '0.1.3'
|
3
|
+
end
|