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 +4 -4
- data/README.md +67 -4
- data/examples/background.png +0 -0
- data/examples/complex_invoice.pdf +1042 -402
- data/examples/complex_invoice.png +0 -0
- data/examples/complex_invoice.rb +1 -1
- data/examples/czech_invoice.pdf +427 -374
- data/examples/czech_invoice.rb +1 -1
- data/examples/international_invoice.pdf +1152 -1
- data/examples/international_invoice.rb +84 -0
- data/examples/simple_invoice.pdf +0 -0
- data/examples/simple_invoice.rb +1 -1
- data/examples/stamp.png +0 -0
- data/lib/invoice_printer/pdf_document.rb +282 -100
- data/lib/invoice_printer/version.rb +1 -1
- data/lib/invoice_printer.rb +8 -0
- data/test/background_test.rb +1 -1
- data/test/dates_box_test.rb +8 -8
- data/test/examples_test.rb +33 -0
- data/test/payment_box_test.rb +10 -10
- data/test/test_ext.rb +7 -7
- data/test/test_helper.rb +3 -0
- metadata +8 -6
- data/examples/background.jpg +0 -0
- data/examples/czech_invoice.jpg +0 -0
- data/examples/example.jpg +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd883b1301d64bf81e14e413d1a51bd7a69bfc6b
|
4
|
+
data.tar.gz: ae4140c675734a8d7a48d6cea50ab473557b044d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
252
|
+
background: File.expand_path('../background.png', __FILE__)
|
190
253
|
)
|
191
254
|
```
|
192
255
|
|
193
256
|
## Copyright
|
194
257
|
|
195
|
-
Copyright 2015-
|
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
|