invoice_printer 2.0.0.beta2 → 2.0.0.beta3
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/Dockerfile +4 -1
- data/bin/invoice_printer +1 -1
- data/docs/COMMAND_LINE.md +1 -1
- data/docs/INSTALLATION.md +10 -0
- data/docs/LIBRARY.md +2 -2
- data/docs/SERVER.md +4 -2
- data/examples/czech_invoice.rb +2 -5
- data/examples/czech_invoice_long.rb +2 -5
- data/examples/international_invoice.rb +2 -5
- data/examples/promo.rb +2 -5
- data/examples/provider_purchaser_lines.rb +2 -5
- data/invoice_printer.gemspec +14 -2
- data/invoice_printer_fonts.gemspec +39 -0
- data/invoice_printer_server.gemspec +1 -0
- data/lib/invoice_printer/pdf_document.rb +7 -15
- data/lib/invoice_printer/version.rb +1 -1
- data/test/examples_test.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0b5acb10995e69d8aba7d44d9e7d71ce5e9b9104cf5883fec574ada600501b0
|
4
|
+
data.tar.gz: 3ccaa20f6baeee71cf879cdf74687e6da7ab6441fa5583199fa547d3e5afd34f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84cf91f9a5f2445dbe62491e7f51c05e4bfaf3d9c5d58881db035a964c2114a9d02fca485f300b15fc8cb87efea05d2c24d60822c1f9c01145dd1eeba62c22cd
|
7
|
+
data.tar.gz: aa5566034f52a87d9c7ee432fc485fd233407a82f591ded208a880f0d214aea3c39cc6241add8bfffbcb3abe07311214cb47ff0daec20f1e7ea4ad5a92b131c8
|
data/Dockerfile
CHANGED
@@ -24,8 +24,11 @@ RUN apk update && apk upgrade
|
|
24
24
|
# Install Ruby and build dependencies
|
25
25
|
RUN apk add build-base bash ruby ruby-etc ruby-dev
|
26
26
|
|
27
|
+
# Install support for builtin fonts
|
28
|
+
RUN gem install invoice_printer_fonts --no-document
|
29
|
+
|
27
30
|
# Install gem from RubyGems.org
|
28
|
-
RUN gem install invoice_printer_server --version 2.0.0.
|
31
|
+
RUN gem install invoice_printer_server --version 2.0.0.beta3 --no-document
|
29
32
|
|
30
33
|
# Clean APK cache
|
31
34
|
RUN rm -rf /var/cache/apk/*
|
data/bin/invoice_printer
CHANGED
data/docs/COMMAND_LINE.md
CHANGED
data/docs/INSTALLATION.md
CHANGED
@@ -12,6 +12,10 @@ Or the server version as:
|
|
12
12
|
|
13
13
|
$ gem install invoice_printer_server
|
14
14
|
|
15
|
+
To have builtin fonts available install:
|
16
|
+
|
17
|
+
$ gem install invoice_printer_fonts
|
18
|
+
|
15
19
|
### With Bundler
|
16
20
|
|
17
21
|
Add this line to your application's Gemfile:
|
@@ -26,6 +30,12 @@ For the server:
|
|
26
30
|
gem 'invoice_printer_server'
|
27
31
|
```
|
28
32
|
|
33
|
+
To have builtin fonts available add:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
gem 'invoice_printer_fonts'
|
37
|
+
```
|
38
|
+
|
29
39
|
And then execute:
|
30
40
|
|
31
41
|
$ bundle
|
data/docs/LIBRARY.md
CHANGED
@@ -233,9 +233,9 @@ InvoicePrinter.print(
|
|
233
233
|
)
|
234
234
|
```
|
235
235
|
|
236
|
-
If you don't have a font around, you can install `
|
236
|
+
If you don't have a font around, you can install `invoice_printer_fonts` gem and specify the supported font name instead.
|
237
237
|
|
238
|
-
|
238
|
+
Supported builtin fonts are: `overpass`, `opensans`, and `ruboto`. Note that searching the path takes preference.
|
239
239
|
|
240
240
|
### Background
|
241
241
|
|
data/docs/SERVER.md
CHANGED
@@ -28,6 +28,8 @@ $ sudo docker run -d -p 9393:9393 -t docker.io/strzibnyj/invoice_printer_server
|
|
28
28
|
```
|
29
29
|
The server will then be available on `0.0.0.0:9393`.
|
30
30
|
|
31
|
+
Docker image already contains the optional `invoice_printer_fonts` gem.
|
32
|
+
|
31
33
|
### As a mountable Rack app
|
32
34
|
|
33
35
|
If you want you can always run the server from your custom program or mount it directly from a Rack app.
|
@@ -56,7 +58,7 @@ Options:
|
|
56
58
|
|
57
59
|
- `document` - JSON representation of the document
|
58
60
|
- `labels` - JSON for labels
|
59
|
-
- `font` - path to font file
|
61
|
+
- `font` - path to font file or builtin font name
|
60
62
|
- `stamp` - path to stamp file
|
61
63
|
- `logo` - path to logotype file
|
62
64
|
- `background` - path to background file
|
@@ -96,7 +98,7 @@ Options:
|
|
96
98
|
|
97
99
|
- `document` - JSON representation of the document
|
98
100
|
- `labels` - JSON for labels
|
99
|
-
- `font` - path to font file
|
101
|
+
- `font` - path to font file or builtin font name
|
100
102
|
- `stamp` - path to stamp file
|
101
103
|
- `logo` - path to logotype file
|
102
104
|
- `background` - path to background file
|
data/examples/czech_invoice.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# This is an example of a Czech invoice.
|
3
|
-
#
|
4
|
-
# Due to the special characters it requires Overpass-Regular.ttf font to be
|
5
|
-
# present in this directory.
|
6
3
|
|
7
4
|
lib = File.expand_path('../../lib', __FILE__)
|
8
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
@@ -81,7 +78,7 @@ invoice = InvoicePrinter::Document.new(
|
|
81
78
|
InvoicePrinter.print(
|
82
79
|
document: invoice,
|
83
80
|
labels: labels,
|
84
|
-
font:
|
81
|
+
font: 'overpass',
|
85
82
|
logo: 'prawn.png',
|
86
83
|
file_name: 'czech_invoice.pdf'
|
87
84
|
)
|
@@ -89,7 +86,7 @@ InvoicePrinter.print(
|
|
89
86
|
InvoicePrinter.print(
|
90
87
|
document: invoice,
|
91
88
|
labels: labels,
|
92
|
-
font:
|
89
|
+
font: 'overpass',
|
93
90
|
logo: 'prawn.png',
|
94
91
|
file_name: 'czech_invoice_a4.pdf',
|
95
92
|
page_size: :a4
|
@@ -1,8 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# This is an example of a Czech invoice.
|
3
|
-
#
|
4
|
-
# Due to the special characters it requires Overpass-Regular.ttf font to be
|
5
|
-
# present in this directory.
|
6
3
|
|
7
4
|
lib = File.expand_path('../../lib', __FILE__)
|
8
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
@@ -81,7 +78,7 @@ invoice = InvoicePrinter::Document.new(
|
|
81
78
|
InvoicePrinter.print(
|
82
79
|
document: invoice,
|
83
80
|
labels: labels,
|
84
|
-
font:
|
81
|
+
font: 'overpass',
|
85
82
|
logo: 'prawn.png',
|
86
83
|
file_name: 'czech_invoice_long.pdf'
|
87
84
|
)
|
@@ -89,7 +86,7 @@ InvoicePrinter.print(
|
|
89
86
|
InvoicePrinter.print(
|
90
87
|
document: invoice,
|
91
88
|
labels: labels,
|
92
|
-
font:
|
89
|
+
font: 'overpass',
|
93
90
|
logo: 'prawn.png',
|
94
91
|
file_name: 'czech_invoice_long_a4.pdf',
|
95
92
|
page_size: :a4
|
@@ -1,8 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# This is an example of a international invoice with Czech labels and English translation.
|
3
|
-
#
|
4
|
-
# Due to the special characters it requires Overpass-Regular.ttf font to be
|
5
|
-
# present in this directory.
|
6
3
|
|
7
4
|
lib = File.expand_path('../../lib', __FILE__)
|
8
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
@@ -82,7 +79,7 @@ invoice = InvoicePrinter::Document.new(
|
|
82
79
|
InvoicePrinter.print(
|
83
80
|
document: invoice,
|
84
81
|
labels: labels,
|
85
|
-
font:
|
82
|
+
font: 'overpass',
|
86
83
|
logo: 'prawn.png',
|
87
84
|
file_name: 'international_invoice.pdf'
|
88
85
|
)
|
@@ -90,7 +87,7 @@ InvoicePrinter.print(
|
|
90
87
|
InvoicePrinter.print(
|
91
88
|
document: invoice,
|
92
89
|
labels: labels,
|
93
|
-
font:
|
90
|
+
font: 'overpass',
|
94
91
|
logo: 'prawn.png',
|
95
92
|
file_name: 'international_invoice_a4.pdf',
|
96
93
|
page_size: :a4
|
data/examples/promo.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# This is an example of a international invoice with Czech labels and English translation.
|
3
|
-
#
|
4
|
-
# Due to the special characters it requires Overpass-Regular.ttf font to be
|
5
|
-
# present in this directory.
|
6
3
|
|
7
4
|
lib = File.expand_path('../../lib', __FILE__)
|
8
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
@@ -78,7 +75,7 @@ invoice = InvoicePrinter::Document.new(
|
|
78
75
|
InvoicePrinter.print(
|
79
76
|
document: invoice,
|
80
77
|
labels: labels,
|
81
|
-
font: File.expand_path('
|
78
|
+
font: File.expand_path('../../../assets/fonts/overpass/Overpass-Regular.ttf', __FILE__),
|
82
79
|
logo: 'logo.png',
|
83
80
|
file_name: 'promo.pdf'
|
84
81
|
)
|
@@ -86,7 +83,7 @@ InvoicePrinter.print(
|
|
86
83
|
InvoicePrinter.print(
|
87
84
|
document: invoice,
|
88
85
|
labels: labels,
|
89
|
-
font: File.expand_path('
|
86
|
+
font: File.expand_path('../../../assets/fonts/overpass/Overpass-Regular.ttf', __FILE__),
|
90
87
|
logo: 'logo.png',
|
91
88
|
file_name: 'promo_a4.pdf',
|
92
89
|
page_size: :a4
|
@@ -1,8 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# This is an example of a Czech invoice.
|
3
|
-
#
|
4
|
-
# Due to the special characters it requires Overpass-Regular.ttf font to be
|
5
|
-
# present in this directory.
|
6
3
|
|
7
4
|
lib = File.expand_path('../../lib', __FILE__)
|
8
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
@@ -96,7 +93,7 @@ invoice = InvoicePrinter::Document.new(
|
|
96
93
|
InvoicePrinter.print(
|
97
94
|
document: invoice,
|
98
95
|
labels: labels,
|
99
|
-
font:
|
96
|
+
font: 'overpass',
|
100
97
|
logo: 'prawn.png',
|
101
98
|
file_name: 'provider_purchaser_lines.pdf'
|
102
99
|
)
|
@@ -104,7 +101,7 @@ InvoicePrinter.print(
|
|
104
101
|
InvoicePrinter.print(
|
105
102
|
document: invoice,
|
106
103
|
labels: labels,
|
107
|
-
font:
|
104
|
+
font: 'overpass',
|
108
105
|
logo: 'prawn.png',
|
109
106
|
file_name: 'provider_purchaser_lines_a4.pdf',
|
110
107
|
page_size: :a4
|
data/invoice_printer.gemspec
CHANGED
@@ -2,11 +2,22 @@ lib = File.expand_path('../lib', __FILE__)
|
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
3
|
require 'invoice_printer/version'
|
4
4
|
|
5
|
-
|
5
|
+
ONLY_SERVER_FILES = [
|
6
6
|
'bin/invoice_printer_server',
|
7
7
|
'lib/invoice_printer/server.rb'
|
8
8
|
]
|
9
9
|
|
10
|
+
ONLY_FONTS_FILES = [
|
11
|
+
'FONTS_LICENSE.txt',
|
12
|
+
'assets/fonts/overpass/OFL-1.1.txt',
|
13
|
+
'assets/fonts/overpass/Overpass-Regular.ttf',
|
14
|
+
'assets/fonts/opensans/Apache-2.0.txt',
|
15
|
+
'assets/fonts/opensans/OpenSans-Regular.ttf',
|
16
|
+
'assets/fonts/roboto/Apache-2.0.txt',
|
17
|
+
'assets/fonts/roboto/Roboto-Regular.ttf',
|
18
|
+
'lib/invoice_printer/fonts.rb'
|
19
|
+
]
|
20
|
+
|
10
21
|
Gem::Specification.new do |spec|
|
11
22
|
spec.name = 'invoice_printer'
|
12
23
|
spec.version = InvoicePrinter::VERSION
|
@@ -20,7 +31,8 @@ Gem::Specification.new do |spec|
|
|
20
31
|
# Remove server files
|
21
32
|
# Remove .pdf files as they take a lot of space
|
22
33
|
package_files = `git ls-files -z`.split("\x0")
|
23
|
-
.reject{ |file|
|
34
|
+
.reject{ |file| ONLY_SERVER_FILES.include?(file) }
|
35
|
+
.reject{ |file| ONLY_FONTS_FILES.include?(file) }
|
24
36
|
.reject{ |file| file.match /.*\.pdf/ }
|
25
37
|
|
26
38
|
spec.files = package_files
|
@@ -0,0 +1,39 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'invoice_printer/version'
|
4
|
+
|
5
|
+
FONTS_FILES = [
|
6
|
+
'LICENSE.txt',
|
7
|
+
'FONTS_LICENSE.txt',
|
8
|
+
'assets/fonts/overpass/OFL-1.1.txt',
|
9
|
+
'assets/fonts/overpass/Overpass-Regular.ttf',
|
10
|
+
'assets/fonts/opensans/Apache-2.0.txt',
|
11
|
+
'assets/fonts/opensans/OpenSans-Regular.ttf',
|
12
|
+
'assets/fonts/roboto/Apache-2.0.txt',
|
13
|
+
'assets/fonts/roboto/Roboto-Regular.ttf',
|
14
|
+
'lib/invoice_printer/fonts.rb'
|
15
|
+
]
|
16
|
+
|
17
|
+
Gem::Specification.new do |spec|
|
18
|
+
spec.name = 'invoice_printer_fonts'
|
19
|
+
spec.version = InvoicePrinter::VERSION
|
20
|
+
spec.authors = ['Josef Strzibny']
|
21
|
+
spec.email = ['strzibny@strzibny.name']
|
22
|
+
spec.summary = 'Super simple PDF invoicing in pure Ruby'
|
23
|
+
spec.description = 'Super simple and fast PDF invoicing in pure Ruby (based on Prawn library).'
|
24
|
+
spec.homepage = 'https://github.com/strzibny/invoice_printer'
|
25
|
+
spec.license = 'MIT'
|
26
|
+
|
27
|
+
# Include only font files
|
28
|
+
spec.files = FONTS_FILES
|
29
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
30
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
31
|
+
spec.require_paths = ['lib']
|
32
|
+
|
33
|
+
spec.required_ruby_version = '>= 2.4'
|
34
|
+
|
35
|
+
spec.add_dependency 'invoice_printer', InvoicePrinter::VERSION
|
36
|
+
|
37
|
+
spec.add_development_dependency 'bundler', '>= 1.7'
|
38
|
+
spec.add_development_dependency 'rake', '>= 10.0'
|
39
|
+
end
|
@@ -145,28 +145,20 @@ module InvoicePrinter
|
|
145
145
|
def use_font(font)
|
146
146
|
if File.exist?(@font)
|
147
147
|
set_font_from_path(@font)
|
148
|
-
elsif @font == 'dejavu'
|
149
|
-
set_dejavu_font
|
150
148
|
else
|
151
|
-
|
149
|
+
set_builtin_font(@font)
|
152
150
|
end
|
153
151
|
end
|
154
152
|
|
155
|
-
|
156
|
-
|
157
|
-
require 'dejavu-fonts'
|
158
|
-
font_name = 'dejavu'
|
153
|
+
def set_builtin_font(font)
|
154
|
+
require 'invoice_printer/fonts'
|
159
155
|
|
160
156
|
@pdf.font_families.update(
|
161
|
-
"#{
|
162
|
-
normal: DejaVu::Fonts.paths[:normal],
|
163
|
-
italic: DejaVu::Fonts.paths[:italic],
|
164
|
-
bold: DejaVu::Fonts.paths[:bold],
|
165
|
-
bold_italic: DejaVu::Fonts.paths[:bold_italic]
|
166
|
-
}
|
157
|
+
"#{font}" => InvoicePrinter::Fonts.paths_for(font)
|
167
158
|
)
|
168
|
-
@pdf.font(
|
169
|
-
|
159
|
+
@pdf.font(font)
|
160
|
+
|
161
|
+
rescue StandardError
|
170
162
|
raise FontFileNotFound, "Font file not found for #{font}"
|
171
163
|
end
|
172
164
|
|
data/test/examples_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: invoice_printer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.beta3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josef Strzibny
|
@@ -117,6 +117,7 @@ files:
|
|
117
117
|
- examples/simple_invoice.rb
|
118
118
|
- examples/stamp.png
|
119
119
|
- invoice_printer.gemspec
|
120
|
+
- invoice_printer_fonts.gemspec
|
120
121
|
- invoice_printer_server.gemspec
|
121
122
|
- lib/invoice_printer.rb
|
122
123
|
- lib/invoice_printer/document.rb
|