prawn_plus 10.0.0 → 10.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a3df6a1bbce8e4d75e3b411204b873dbca62a6913a8de04efcee18429746fe2
4
- data.tar.gz: 476146ef2a7b988b54d374538185689c53154f8f397b523e242fa4ada63a4287
3
+ metadata.gz: a42eb8f2ba22bef152f7e65835428c351440ad9f459899e95845768bef3dc2b8
4
+ data.tar.gz: 8b489ebc9b9fc907abef25ce26ab4e5426523f975ad6df82dae6527c05c451ad
5
5
  SHA512:
6
- metadata.gz: 6eb86c793d0786c7363368db13391cfd3562f5dd4aec6ca3e45356cd7d2f9f32067e3882898d40334037b4b0bbb6028716f98d76bb0552bb5617eb55eabae868
7
- data.tar.gz: 3a8318182f7c2499fc4699ca42fc19b1dbed269d98a52e36f38425a3621d5f4b7a6c2274be3affd9f2929d0435b281169cde2c3b90cb7cb9ddf170fe205dd1da
6
+ metadata.gz: d9a37c02204c81e96344fcf7c1d62cc0300da0dc7bc7e6842d1c55c01d8214a001bb9e18d677775359dac5940bab9af02fd41fd05a6d48382813c78aee8c5a62
7
+ data.tar.gz: ca44f32b3e50e38120bd1e556e241a3277446268fa5604ef01608ef743eb817fff3725ed79d3e508fceec00e38f5a9d5561c61dbd6719f498ed15467724db650
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,4 +1,4 @@
1
- # Apache License
1
+ = Apache License
2
2
 
3
3
  Version 2.0, January 2004
4
4
 
@@ -6,7 +6,7 @@ http://www.apache.org/licenses
6
6
 
7
7
  TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
8
 
9
- ## 1. Definitions
9
+ == 1. Definitions
10
10
 
11
11
  "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by
12
12
  Sections 1 through 9 of this document.
@@ -54,14 +54,14 @@ Contribution."
54
54
  "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a
55
55
  Contribution has been received by Licensor and subsequently incorporated within the Work.
56
56
 
57
- ## 2. Grant of Copyright License
57
+ == 2. Grant of Copyright License
58
58
 
59
59
  Subject to the terms and conditions of this License, each Contributor hereby grants to You a
60
60
  perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to
61
61
  reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and
62
62
  distribute the Work and such Derivative Works in Source or Object form.
63
63
 
64
- ## 3. Grant of Patent License
64
+ == 3. Grant of Patent License
65
65
 
66
66
  Subject to the terms and conditions of this License, each Contributor hereby grants to You a
67
67
  perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
@@ -74,39 +74,38 @@ a Contribution incorporated within the Work constitutes direct or contributory p
74
74
  then any patent licenses granted to You under this License for that Work shall terminate as of the
75
75
  date such litigation is filed.
76
76
 
77
- ## 4. Redistribution
77
+ == 4. Redistribution
78
78
 
79
79
  You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with
80
80
  or without modifications, and in Source or Object form, provided that You meet the following
81
81
  conditions:
82
82
 
83
- 1. You must give any other recipients of the Work or Derivative Works a copy of this License; and
83
+ . You must give any other recipients of the Work or Derivative Works a copy of this License; and
84
84
 
85
- 2. You must cause any modified files to carry prominent notices stating that You changed the
86
- files; and
85
+ . You must cause any modified files to carry prominent notices stating that You changed the files;
86
+ and
87
87
 
88
- 3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright,
89
- patent, trademark, and attribution notices from the Source form of the Work, excluding those
90
- notices that do not pertain to any part of the Derivative Works; and
88
+ . You must retain, in the Source form of any Derivative Works that You distribute, all copyright,
89
+ patent, trademark, and attribution notices from the Source form of the Work, excluding those
90
+ notices that do not pertain to any part of the Derivative Works; and
91
91
 
92
- 4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative
93
- Works that You distribute must include a readable copy of the attribution notices contained
94
- within such NOTICE file, excluding those notices that do not pertain to any part of the
95
- Derivative Works, in at least one of the following places: within a NOTICE text file
96
- distributed as part of the Derivative Works; within the Source form or documentation, if
97
- provided along with the Derivative Works; or, within a display generated by the Derivative
98
- Works, if and wherever such third-party notices normally appear. The contents of the NOTICE
99
- file are for informational purposes only and do not modify the License. You may add Your own
100
- attribution notices within Derivative Works that You distribute, alongside or as an addendum to
101
- the NOTICE text from the Work, provided that such additional attribution notices cannot be
102
- construed as modifying the License.
92
+ . If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works
93
+ that You distribute must include a readable copy of the attribution notices contained within such
94
+ NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in
95
+ at least one of the following places: within a NOTICE text file distributed as part of the
96
+ Derivative Works; within the Source form or documentation, if provided along with the Derivative
97
+ Works; or, within a display generated by the Derivative Works, if and wherever such third-party
98
+ notices normally appear. The contents of the NOTICE file are for informational purposes only and
99
+ do not modify the License. You may add Your own attribution notices within Derivative Works that
100
+ You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such
101
+ additional attribution notices cannot be construed as modifying the License.
103
102
 
104
103
  You may add Your own copyright statement to Your modifications and may provide additional or
105
104
  different license terms and conditions for use, reproduction, or distribution of Your modifications,
106
105
  or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of
107
106
  the Work otherwise complies with the conditions stated in this License.
108
107
 
109
- ## 5. Submission of Contributions
108
+ == 5. Submission of Contributions
110
109
 
111
110
  Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the
112
111
  Work by You to the Licensor shall be under the terms and conditions of this License, without any
@@ -114,13 +113,13 @@ additional terms or conditions. Notwithstanding the above, nothing herein shall
114
113
  the terms of any separate license agreement you may have executed with Licensor regarding such
115
114
  Contributions.
116
115
 
117
- ## 6. Trademarks
116
+ == 6. Trademarks
118
117
 
119
118
  This License does not grant permission to use the trade names, trademarks, service marks, or product
120
119
  names of the Licensor, except as required for reasonable and customary use in describing the origin
121
120
  of the Work and reproducing the content of the NOTICE file.
122
121
 
123
- ## 7. Disclaimer of Warranty
122
+ == 7. Disclaimer of Warranty
124
123
 
125
124
  Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each
126
125
  Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -129,7 +128,7 @@ TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. Y
129
128
  responsible for determining the appropriateness of using or redistributing the Work and assume any
130
129
  risks associated with Your exercise of permissions under this License.
131
130
 
132
- ## 8. Limitation of Liability
131
+ == 8. Limitation of Liability
133
132
 
134
133
  In no event and under no legal theory, whether in tort (including negligence), contract, or
135
134
  otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or
@@ -139,7 +138,7 @@ License or out of the use or inability to use the Work (including but not limite
139
138
  loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial
140
139
  damages or losses), even if such Contributor has been advised of the possibility of such damages.
141
140
 
142
- ## 9. Accepting Warranty or Additional Liability
141
+ == 9. Accepting Warranty or Additional Liability
143
142
 
144
143
  While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee
145
144
  for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights
@@ -151,11 +150,11 @@ additional liability.
151
150
 
152
151
  END OF TERMS AND CONDITIONS
153
152
 
154
- Copyright 2012 [Alchemists](https://www.alchemists.io).
153
+ Copyright link:https://www.alchemists.io[Alchemists].
155
154
 
156
155
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
157
- compliance with the License. You may obtain a [copy](http://www.apache.org/licenses/LICENSE-2.0) of
158
- the License.
156
+ compliance with the License. You may obtain a link:https://www.apache.org/licenses/LICENSE-2.0[copy]
157
+ of the License.
159
158
 
160
159
  Unless required by applicable law or agreed to in writing, software distributed under the License is
161
160
  distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
@@ -0,0 +1,176 @@
1
+ :toc: macro
2
+ :toclevels: 5
3
+ :figure-caption!:
4
+
5
+ = Prawn+
6
+
7
+ [link=http://badge.fury.io/rb/prawn_plus]
8
+ image::https://badge.fury.io/rb/prawn_plus.svg[Gem Version]
9
+ [link=https://circleci.com/gh/bkuhlmann/prawn_plus]
10
+ image::https://circleci.com/gh/bkuhlmann/prawn_plus.svg?style=svg[Circle CI Status]
11
+
12
+ toc::[]
13
+
14
+ == Features
15
+
16
+ * Loads the https://github.com/prawnpdf/prawn[Prawn] gem by default (no Gemfile entry necessary).
17
+ * Registers PDF as a MIME type.
18
+ * Registers a template handler for rendering "`.prawn`" template view files.
19
+
20
+ == Requirements
21
+
22
+ . https://www.ruby-lang.org[Ruby 2.7.x].
23
+ . http://rubyonrails.org[Ruby on Rails 6.0.x].
24
+ . https://github.com/prawnpdf/prawn[Prawn].
25
+
26
+ == Setup
27
+
28
+ === Production
29
+
30
+ To install, run:
31
+
32
+ [source,bash]
33
+ ----
34
+ gem install prawn_plus
35
+ ----
36
+
37
+ Add the following to your Gemfile:
38
+
39
+ [source,ruby]
40
+ ----
41
+ gem "prawn_plus"
42
+ ----
43
+
44
+ === Development
45
+
46
+ To contribute, run:
47
+
48
+ [source,bash]
49
+ ----
50
+ git clone https://github.com/bkuhlmann/prawn_plus.git
51
+ cd prawn_plus
52
+ bin/setup
53
+ ----
54
+
55
+ You can also use the IRB console for direct access to all objects:
56
+
57
+ [source,bash]
58
+ ----
59
+ bin/console
60
+ ----
61
+
62
+ == Usage
63
+
64
+ === Views
65
+
66
+ Within your views you can craft Prawn templates using Ruby code. For example, assuming there are
67
+ document resources, then the following structure might exist:
68
+
69
+ ....
70
+ /views/documents/show.html.slim
71
+ /views/documents/show.pdf.prawn
72
+ ....
73
+
74
+ The `show.html.slim` could have a link to the PDF download. Example:
75
+
76
+ ....
77
+ = link_to "PDF Download", action: "show", id: @document.id, format: "pdf"
78
+ ....
79
+
80
+ The `show.pdf.prawn` file would contain the Prawn syntax for crafting the PDF. A simple example
81
+ might look like this:
82
+
83
+ [source,ruby]
84
+ ----
85
+ pdf.text "Hello, I'm a PDF!"
86
+ ----
87
+
88
+ ...which would render the following output:
89
+
90
+ image::https://www.alchemists.io/images/projects/prawn_plus/screenshots/basic.png[Basic Example]
91
+
92
+ You could also render a more complex PDF with tabular information, for example:
93
+
94
+ [source,ruby]
95
+ ----
96
+ pdf.text "Metals"
97
+ pdf.move_down 10
98
+ pdf.font_size = 10
99
+
100
+ data = [
101
+ ["Name", "Atomic Number", "Price"],
102
+ ["Mercury", "80", number_to_currency(10)],
103
+ ["Platinum", "78", number_to_currency(25)],
104
+ ["Titanium", "22", number_to_currency(50)]
105
+ ]
106
+
107
+ pdf.table data, header: true, column_widths: [100, 50, 50], row_colors: ["FFFFFF", "E5ECF9"] do
108
+ columns(0).align = :left
109
+ columns(1..2).align = :right
110
+ row(0).text_color = "FFFFFF"
111
+ row(0).background_color = "000000"
112
+ row(0).columns(0..2).font_style = :bold
113
+ row(0).columns(0..2).align = :center
114
+ end
115
+ ----
116
+
117
+ ...which would render the following output:
118
+
119
+ image::https://www.alchemists.io/images/projects/prawn_plus/screenshots/complex.png[Complex Example]
120
+
121
+ _NOTE: The `pdf` object must always be referenced when making using of the Prawn syntax - it is
122
+ initialized for you as a Prawn::Document instance._
123
+
124
+ === Controllers
125
+
126
+ Within your controller, only the `respond_to` method is required. Example:
127
+
128
+ [source,ruby]
129
+ ----
130
+ class DocumentsController < ApplicationController
131
+ respond_to :pdf
132
+
133
+ def show
134
+ end
135
+ end
136
+ ----
137
+
138
+ That’s it!
139
+
140
+ == Tests
141
+
142
+ To test, run:
143
+
144
+ [source,bash]
145
+ ----
146
+ bundle exec rake
147
+ ----
148
+
149
+ == Versioning
150
+
151
+ Read link:https://semver.org[Semantic Versioning] for details. Briefly, it means:
152
+
153
+ * Major (X.y.z) - Incremented for any backwards incompatible public API changes.
154
+ * Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
155
+ * Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
156
+
157
+ == Code of Conduct
158
+
159
+ Please note that this project is released with a link:CODE_OF_CONDUCT.adoc[CODE OF CONDUCT]. By
160
+ participating in this project you agree to abide by its terms.
161
+
162
+ == Contributions
163
+
164
+ Read link:CONTRIBUTING.adoc[CONTRIBUTING] for details.
165
+
166
+ == License
167
+
168
+ Read link:LICENSE.adoc[LICENSE] for details.
169
+
170
+ == History
171
+
172
+ Read link:CHANGES.adoc[CHANGES] for details.
173
+
174
+ == Credits
175
+
176
+ Engineered by link:https://www.alchemists.io/team/brooke_kuhlmann.html[Brooke Kuhlmann].
@@ -3,20 +3,9 @@
3
3
  module PrawnPlus
4
4
  # Gem identity information.
5
5
  module Identity
6
- def self.name
7
- "prawn_plus"
8
- end
9
-
10
- def self.label
11
- "Prawn+"
12
- end
13
-
14
- def self.version
15
- "10.0.0"
16
- end
17
-
18
- def self.version_label
19
- "#{label} #{version}"
20
- end
6
+ NAME = "prawn_plus"
7
+ LABEL = "Prawn+"
8
+ VERSION = "10.1.0"
9
+ VERSION_LABEL = "#{LABEL} #{VERSION}"
21
10
  end
22
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn_plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.0
4
+ version: 10.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -10,9 +10,9 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIC/jCCAeagAwIBAgIBAjANBgkqhkiG9w0BAQsFADAlMSMwIQYDVQQDDBpicm9v
14
- a2UvREM9YWxjaGVtaXN0cy9EQz1pbzAeFw0xOTAyMTcxNjAxMTFaFw0yMDAyMTcx
15
- NjAxMTFaMCUxIzAhBgNVBAMMGmJyb29rZS9EQz1hbGNoZW1pc3RzL0RDPWlvMIIB
13
+ MIIC/jCCAeagAwIBAgIBAzANBgkqhkiG9w0BAQsFADAlMSMwIQYDVQQDDBpicm9v
14
+ a2UvREM9YWxjaGVtaXN0cy9EQz1pbzAeFw0yMDAzMTUxNDQ1MzJaFw0yMTAzMTUx
15
+ NDQ1MzJaMCUxIzAhBgNVBAMMGmJyb29rZS9EQz1hbGNoZW1pc3RzL0RDPWlvMIIB
16
16
  IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6l1qpXTiomH1RfMRloyw7MiE
17
17
  xyVx/x8Yc3EupdH7uhNaTXQGyORN6aOY//1QXXMHIZ9tW74nZLhesWMSUMYy0XhB
18
18
  brs+KkurHnc9FnEJAbG7ebGvl/ncqZt72nQvaxpDxvuCBHgJAz+8i5wl6FhLw+oT
@@ -20,15 +20,15 @@ cert_chain:
20
20
  D5vkU0YlAm1r98BymuJlcQ1qdkVEI1d48ph4kcS0S0nv1RiuyVb6TCAR3Nu3VaVq
21
21
  3fPzZKJLZBx67UvXdbdicWPiUR75elI4PXpLIic3xytaF52ZJYyKZCNZJhNwfQID
22
22
  AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU0nzow9vc
23
- 2CdikiiE3fJhP/gY4ggwDQYJKoZIhvcNAQELBQADggEBANgfX7kPZkJvsbdWMvbe
24
- DUUYxRTqTUzCDpLd2p3sQvgLMKjTNSKt6CFq/kh+98b6RCgO6DqiVfxvOEq02dvf
25
- ebMN/ylQqan2FgiAs1rpP0/D4C0MlBjoDktsT+2IyLol1KmkDB20ExJ4Sf1GRNdA
26
- hpWOtcgqHtmrc7xzgB6BuyoYufrKKUlCO3ewTM4C375D2qO7hIdKuMOO3CdPMtSk
27
- OrWpbzCL+nbbXqeoqiHgZaUvcyyQrGj5sQRxMTzuMXzzQxtHnuTuKrcz16HMTX/O
28
- dKvURM+1PwDCzC5tvRwjhUJIizau6+MtkFCvJHmaAj1aZL3odcPejHj5Hxt/0CUW
29
- y84=
23
+ 2CdikiiE3fJhP/gY4ggwDQYJKoZIhvcNAQELBQADggEBAIHhAlD3po4sTYqacXaQ
24
+ XI9jIhrfMy//2PgbHWcETtlJPBeNUbbSNBABcllUHKqYsVDlSvSmss034KSWNR8F
25
+ bF1GcloicyvcCC4y6IoW4it0COAcdeaaxkxiBSgKdQFpff9REnDlIKK4uQ9lLxIo
26
+ Y2G5xubiziKZkyfWFuSr67PIjW3Bu673D1JVBArhA1qbgQmYQcy1CkGOjo+iO8Nf
27
+ 7u/QSfBHb+r/bXhKscDgPpnKwbUmvgO2+94zJG9KsrmIydlzYfsD09aXKx0t6Xy4
28
+ 2XV8FRa7/JimI07sPLC13eLY3xd/aYTi85Z782KIA4j0G8XEEWAX0ouBhlXPocZv
29
+ QWc=
30
30
  -----END CERTIFICATE-----
31
- date: 2020-01-01 00:00:00.000000000 Z
31
+ date: 2020-04-01 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: prawn
@@ -204,42 +204,42 @@ dependencies:
204
204
  requirements:
205
205
  - - "~>"
206
206
  - !ruby/object:Gem::Version
207
- version: '5.4'
207
+ version: '6.0'
208
208
  type: :development
209
209
  prerelease: false
210
210
  version_requirements: !ruby/object:Gem::Requirement
211
211
  requirements:
212
212
  - - "~>"
213
213
  - !ruby/object:Gem::Version
214
- version: '5.4'
214
+ version: '6.0'
215
215
  - !ruby/object:Gem::Dependency
216
216
  name: rspec-rails
217
217
  requirement: !ruby/object:Gem::Requirement
218
218
  requirements:
219
219
  - - "~>"
220
220
  - !ruby/object:Gem::Version
221
- version: '3.9'
221
+ version: '4.0'
222
222
  type: :development
223
223
  prerelease: false
224
224
  version_requirements: !ruby/object:Gem::Requirement
225
225
  requirements:
226
226
  - - "~>"
227
227
  - !ruby/object:Gem::Version
228
- version: '3.9'
228
+ version: '4.0'
229
229
  - !ruby/object:Gem::Dependency
230
230
  name: rubocop
231
231
  requirement: !ruby/object:Gem::Requirement
232
232
  requirements:
233
233
  - - "~>"
234
234
  - !ruby/object:Gem::Version
235
- version: '0.78'
235
+ version: '0.79'
236
236
  type: :development
237
237
  prerelease: false
238
238
  version_requirements: !ruby/object:Gem::Requirement
239
239
  requirements:
240
240
  - - "~>"
241
241
  - !ruby/object:Gem::Version
242
- version: '0.78'
242
+ version: '0.79'
243
243
  - !ruby/object:Gem::Dependency
244
244
  name: rubocop-performance
245
245
  requirement: !ruby/object:Gem::Requirement
@@ -288,36 +288,37 @@ dependencies:
288
288
  requirements:
289
289
  - - "~>"
290
290
  - !ruby/object:Gem::Version
291
- version: '0.17'
291
+ version: '0.18'
292
292
  type: :development
293
293
  prerelease: false
294
294
  version_requirements: !ruby/object:Gem::Requirement
295
295
  requirements:
296
296
  - - "~>"
297
297
  - !ruby/object:Gem::Version
298
- version: '0.17'
298
+ version: '0.18'
299
299
  description:
300
300
  email:
301
301
  - brooke@alchemists.io
302
302
  executables: []
303
303
  extensions: []
304
304
  extra_rdoc_files:
305
- - README.md
306
- - LICENSE.md
305
+ - README.adoc
306
+ - LICENSE.adoc
307
307
  files:
308
- - LICENSE.md
309
- - README.md
308
+ - LICENSE.adoc
309
+ - README.adoc
310
310
  - lib/prawn_plus.rb
311
311
  - lib/prawn_plus/identity.rb
312
312
  - lib/prawn_plus/railtie.rb
313
313
  - lib/prawn_plus/template_handlers/prawn.rb
314
- homepage: https://github.com/bkuhlmann/prawn_plus
314
+ homepage: https://www.alchemists.io/projects/prawn_plus
315
315
  licenses:
316
316
  - Apache-2.0
317
317
  metadata:
318
- source_code_uri: https://github.com/bkuhlmann/prawn_plus
319
- changelog_uri: https://github.com/bkuhlmann/prawn_plus/blob/master/CHANGES.md
320
318
  bug_tracker_uri: https://github.com/bkuhlmann/prawn_plus/issues
319
+ changelog_uri: https://www.alchemists.io/projects/prawn_plus/changes.html
320
+ documentation_uri: https://www.alchemists.io/projects/prawn_plus
321
+ source_code_uri: https://github.com/bkuhlmann/prawn_plus
321
322
  post_install_message:
322
323
  rdoc_options: []
323
324
  require_paths:
metadata.gz.sig CHANGED
Binary file
data/README.md DELETED
@@ -1,155 +0,0 @@
1
- <p align="center">
2
- <img src="prawn_plus.png" alt="Prawn+ Icon"/>
3
- </p>
4
-
5
- # Prawn+
6
-
7
- [![Gem Version](https://badge.fury.io/rb/prawn_plus.svg)](http://badge.fury.io/rb/prawn_plus)
8
- [![Code Climate Maintainability](https://api.codeclimate.com/v1/badges/11437f0567f0cd96d04e/maintainability)](https://codeclimate.com/github/bkuhlmann/prawn_plus/maintainability)
9
- [![Code Climate Test Coverage](https://api.codeclimate.com/v1/badges/11437f0567f0cd96d04e/test_coverage)](https://codeclimate.com/github/bkuhlmann/prawn_plus/test_coverage)
10
- [![Circle CI Status](https://circleci.com/gh/bkuhlmann/prawn_plus.svg?style=svg)](https://circleci.com/gh/bkuhlmann/prawn_plus)
11
-
12
- <!-- Tocer[start]: Auto-generated, don't remove. -->
13
-
14
- ## Table of Contents
15
-
16
- - [Features](#features)
17
- - [Requirements](#requirements)
18
- - [Setup](#setup)
19
- - [Usage](#usage)
20
- - [Views](#views)
21
- - [Controllers](#controllers)
22
- - [Tests](#tests)
23
- - [Versioning](#versioning)
24
- - [Code of Conduct](#code-of-conduct)
25
- - [Contributions](#contributions)
26
- - [License](#license)
27
- - [History](#history)
28
- - [Credits](#credits)
29
-
30
- <!-- Tocer[finish]: Auto-generated, don't remove. -->
31
-
32
- ## Features
33
-
34
- - Loads the [Prawn](https://github.com/prawnpdf/prawn) gem by default (no Gemfile entry necessary).
35
- - Registers PDF as a MIME type.
36
- - Registers a template handler for rendering ".prawn" template view files.
37
-
38
- ## Requirements
39
-
40
- 1. [Ruby 2.6.x](https://www.ruby-lang.org).
41
- 1. [Ruby on Rails 5.x.x](http://rubyonrails.org).
42
- 1. [Prawn](https://github.com/prawnpdf/prawn).
43
-
44
- ## Setup
45
-
46
- Type the following to install:
47
-
48
- gem install prawn_plus
49
-
50
- Add the following to your Gemfile:
51
-
52
- gem "prawn_plus"
53
-
54
- ## Usage
55
-
56
- ### Views
57
-
58
- Within your views you can craft Prawn templates using Ruby code. For example, assuming there are
59
- document resources, then the following structure might exist:
60
-
61
- /views/documents/show.html.slim
62
- /views/documents/show.pdf.prawn
63
-
64
- The `show.html.slim` could have a link to the PDF download. Example:
65
-
66
- = link_to "PDF Download", action: "show", id: @document.id, format: "pdf"
67
-
68
- The `show.pdf.prawn` file would contain the Prawn syntax for crafting the PDF. A simple example
69
- might look like this:
70
-
71
- pdf.text "Hello, I'm a PDF!"
72
-
73
- ...which would render the following output:
74
-
75
- [![Basic Example](https://github.com/bkuhlmann/prawn_plus/raw/master/doc/examples/basic.png)](https://github.com/bkuhlmann/prawn_plus)
76
-
77
- You could also render a more complex PDF with tabular information, for example:
78
-
79
- pdf.text "Metals"
80
- pdf.move_down 10
81
- pdf.font_size = 10
82
-
83
- data = [
84
- ["Name", "Atomic Number", "Price"],
85
- ["Mercury", "80", number_to_currency(10)],
86
- ["Platinum", "78", number_to_currency(25)],
87
- ["Titanium", "22", number_to_currency(50)]
88
- ]
89
-
90
- pdf.table data, header: true, column_widths: [100, 50, 50], row_colors: ["FFFFFF", "E5ECF9"] do
91
- columns(0).align = :left
92
- columns(1..2).align = :right
93
- row(0).text_color = "FFFFFF"
94
- row(0).background_color = "000000"
95
- row(0).columns(0..2).font_style = :bold
96
- row(0).columns(0..2).align = :center
97
- end
98
-
99
- ...which would render the following output:
100
-
101
- [![Complex Example](https://github.com/bkuhlmann/prawn_plus/raw/master/doc/examples/complex.png)](https://github.com/bkuhlmann/prawn_plus)
102
-
103
- *NOTE: The `pdf` object must always be referenced when making using of the Prawn syntax - it is
104
- initialized for you as a Prawn::Document instance.*
105
-
106
- ### Controllers
107
-
108
- Within your controller, only the `respond_to` method is required. Example:
109
-
110
- class DocumentsController < ApplicationController
111
- respond_to :pdf
112
-
113
- def show
114
- end
115
- end
116
-
117
- That's it!
118
-
119
- ## Tests
120
-
121
- To test, run:
122
-
123
- bundle exec rake
124
-
125
- ## Versioning
126
-
127
- Read [Semantic Versioning](https://semver.org) for details. Briefly, it means:
128
-
129
- - Major (X.y.z) - Incremented for any backwards incompatible public API changes.
130
- - Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
131
- - Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
132
-
133
- ## Code of Conduct
134
-
135
- Please note that this project is released with a [CODE OF CONDUCT](CODE_OF_CONDUCT.md). By
136
- participating in this project you agree to abide by its terms.
137
-
138
- ## Contributions
139
-
140
- Read [CONTRIBUTING](CONTRIBUTING.md) for details.
141
-
142
- ## License
143
-
144
- Copyright 2012 [Alchemists](https://www.alchemists.io).
145
- Read [LICENSE](LICENSE.md) for details.
146
-
147
- ## History
148
-
149
- Read [CHANGES](CHANGES.md) for details.
150
- Built with [Gemsmith](https://github.com/bkuhlmann/gemsmith).
151
-
152
- ## Credits
153
-
154
- Developed by [Brooke Kuhlmann](https://www.alchemists.io) at
155
- [Alchemists](https://www.alchemists.io).