invoice_printer 0.0.8 → 0.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1a1a8627880008c1a2649c81e9c111293174f7a
4
- data.tar.gz: f3b9a8bbd8f68c316497ef0d20c41d7bcfe43585
3
+ metadata.gz: fd883b1301d64bf81e14e413d1a51bd7a69bfc6b
4
+ data.tar.gz: ae4140c675734a8d7a48d6cea50ab473557b044d
5
5
  SHA512:
6
- metadata.gz: 64c5b2e41e6699883cef4771215cc5010519dcbaf81c37a2807347e6a5529aa3fe63c890d4f3f9cf1d9eef29f7a24775bafac185b410a11fdbc52ec96538d2bb
7
- data.tar.gz: fa516cb4c41cdf47e70de492bac1fee3411db89af8c795af1f706b83792791bbe450068c39295985dc9d15b5fb38d7e8063180e803f900f8048384eb2694b007
6
+ metadata.gz: 27898b9d38d273d53b40029db2b278a5999424da9e808ad32bf104afc7aae8133cdbda60c6afa731b0c100a2ae01f0bd1bef1895c9bf4c7d5de1911d1a842488
7
+ data.tar.gz: b7fac7291599fa038ddaf3457735ee19da5426b90acbb60e1fc245c659ed32dcd0acbd9261b291c97f1cbba81e0750688904b461fa150001d4fde6ba09cbb7d3
data/README.md CHANGED
@@ -22,7 +22,7 @@ See more usecases in the `examples/` directory.
22
22
  - Configurable items' table with item description, quantity, unit, price per unit, tax and item's total amount fields
23
23
  - Final subtotal/tax/total info box
24
24
  - Page numbers
25
- - Configurable labels
25
+ - Configurable labels & sublabels (optional little labels)
26
26
  - Configurable font file
27
27
  - Logotype (as image scaled to fit 50px of height)
28
28
  - Background (as image)
@@ -65,6 +65,11 @@ InvoicePrinter.print(
65
65
  document: invoice,
66
66
  file_name: 'invoice.pdf'
67
67
  )
68
+
69
+ # Or render PDF directly
70
+ InvoicePrinter.render(
71
+ document: invoice
72
+ )
68
73
  ```
69
74
 
70
75
  Here is an full example for creating the document object:
@@ -114,6 +119,29 @@ invoice = InvoicePrinter::Document.new(
114
119
  )
115
120
  ```
116
121
 
122
+ ### Ruby on Rails
123
+
124
+ If you want to use InvoicePrinter for printing PDF documents directly from Rails
125
+ actions, you can:
126
+
127
+ ```ruby
128
+ # GET /invoices/1
129
+ def show
130
+ invoice = InvoicePrinter::Document.new(...)
131
+
132
+ respond_to do |format|
133
+ format.pdf {
134
+ @pdf = InvoicePrinter.render(
135
+ document: invoice
136
+ )
137
+ send_data @pdf, type: 'application/pdf', disposition: 'inline'
138
+ }
139
+ end
140
+ end
141
+ ```
142
+
143
+ ## Customization
144
+
117
145
  ### Localization
118
146
 
119
147
  To localize your documents you can set both global defaults or instance
@@ -166,6 +194,41 @@ InvoicePrinter.labels = {
166
194
  }
167
195
  ```
168
196
 
197
+ You can also use sublabels feature to provide the document in two languages:
198
+
199
+ ```ruby
200
+ labels = {
201
+ ...
202
+ }
203
+
204
+ sublabels = {
205
+ name: 'Faktura',
206
+ provider: 'Prodejce',
207
+ purchaser: 'Kupující',
208
+ tax_id: 'IČ',
209
+ tax_id2: 'DIČ',
210
+ payment: 'Forma úhrady',
211
+ payment_by_transfer: 'Platba na následující účet:',
212
+ account_number: 'Číslo účtu',
213
+ issue_date: 'Datum vydání',
214
+ due_date: 'Datum splatnosti',
215
+ item: 'Položka',
216
+ quantity: 'Počet',
217
+ unit: 'MJ',
218
+ price_per_item: 'Cena za položku',
219
+ amount: 'Celkem bez daně',
220
+ subtotal: 'Cena bez daně',
221
+ tax: 'DPH 21 %',
222
+ total: 'Celkem'
223
+ }
224
+
225
+ labels.merge!({ sublabels: sublabels })
226
+
227
+ ...
228
+ ```
229
+
230
+ Now the document will have a little sublabels next to the original labels in Czech.
231
+
169
232
  ### Font
170
233
 
171
234
  To support specific characters you might need to specify a TTF font to be used:
@@ -181,17 +244,17 @@ We recommend you DejaVuSans and Overpass fonts.
181
244
 
182
245
  ### Background
183
246
 
184
- To include a background image you might need to create the file according to the size and resolution to be used (see: [examples/background.jpg](https://github.com/strzibny/invoice_printer/blob/master/examples/background.jpg)):
247
+ To include a background image you might need to create the file according to the size and resolution to be used (see: [examples/background.png](https://github.com/strzibny/invoice_printer/blob/master/examples/background.png)):
185
248
 
186
249
  ``` ruby
187
250
  InvoicePrinter.print(
188
251
  ...
189
- background: File.expand_path('../background.jpg', __FILE__)
252
+ background: File.expand_path('../background.png', __FILE__)
190
253
  )
191
254
  ```
192
255
 
193
256
  ## Copyright
194
257
 
195
- Copyright 2015-2016 © [Josef Strzibny](http://strzibny.name/). MIT licensed.
258
+ Copyright 2015-2017 © [Josef Strzibny](http://strzibny.name/). MIT licensed.
196
259
 
197
260
  Originally extracted from and created for an open source single-entry invoicing app [InvoiceBar](https://github.com/strzibny/invoicebar).
Binary file