obf 0.9.8.32 → 0.9.8.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/obf/pdf.rb +108 -111
- 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: 65381b28a81a2f51dbd9274cb1f58bf474bc9386f4f508c818485551e25160bd
|
4
|
+
data.tar.gz: dc6ba54c37d84ccf783bf766ab5c477723c144df634d6081c13549449b5fc2b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0232d5e377bdf2c0d1882a4e9d473b73c2fab8e931333114bbc354a36ef8455ce1462af7c3686e5a949901f0b703f29c69ab4528b457622f3e65313bcf7a381
|
7
|
+
data.tar.gz: 2cd07ffd2f3cbf8fd665f4a42b3054a5df678f58adc2348db4fe14dbd9af85293f2942db838a095fd1d81c5d1ebb6768e3c4d28e078302e81136f7999ced3be3
|
data/lib/obf/pdf.rb
CHANGED
@@ -45,24 +45,23 @@ module OBF::PDF
|
|
45
45
|
pdf = Prawn::Document.new(doc_opts)
|
46
46
|
# remember: https://www.alphabet-type.com/tools/charset-checker/
|
47
47
|
pdf.font_families.update('THFahKwangBold' => {
|
48
|
-
normal:
|
48
|
+
normal: File.expand_path('../../THFahKwangBold.ttf', __FILE__)
|
49
49
|
})
|
50
50
|
pdf.font_families.update('MiedingerBook' => {
|
51
|
-
normal:
|
51
|
+
normal: File.expand_path('../../MiedingerBook.ttf', __FILE__)
|
52
52
|
})
|
53
53
|
pdf.font_families.update('Arial' => {
|
54
|
-
normal:
|
54
|
+
normal: File.expand_path('../../Arial.ttf', __FILE__)
|
55
55
|
})
|
56
56
|
pdf.font_families.update('TimesNewRoman' => {
|
57
|
-
normal:
|
57
|
+
normal: File.expand_path('../../TimesNewRoman.ttf', __FILE__)
|
58
58
|
})
|
59
59
|
default_font = 'TimesNewRoman'
|
60
60
|
if opts['font'] && !opts['font'].match(/TimesNewRoman/) && File.exists?(opts['font'])
|
61
61
|
pdf.font_families.update('DocDefault' => {
|
62
|
-
normal:
|
62
|
+
normal: file: opts['font']
|
63
63
|
})
|
64
64
|
default_font = 'DocDefault'
|
65
|
-
else
|
66
65
|
end
|
67
66
|
pdf.fallback_fonts = ['TimesNewRoman', 'THFahKwangBold', 'MiedingerBook', 'Helvetica']
|
68
67
|
pdf.font(default_font)
|
@@ -119,7 +118,7 @@ module OBF::PDF
|
|
119
118
|
else
|
120
119
|
build_page(pdf, obj, {
|
121
120
|
'headerless' => !!opts['headerless'],
|
122
|
-
'font' =>
|
121
|
+
'font' => default_font,
|
123
122
|
'text_on_top' => !!opts['text_on_top'],
|
124
123
|
'transparent_background' => !!opts['transparent_background'],
|
125
124
|
'symbol_background' => opts['symbol_background'],
|
@@ -154,98 +153,112 @@ module OBF::PDF
|
|
154
153
|
page_num = options['pages'][obj['id']].to_i
|
155
154
|
pdf.add_dest("page#{page_num}", pdf.dest_fit) if options['links']
|
156
155
|
end
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
pdf.
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
end
|
156
|
+
pdf.font('Arial') do
|
157
|
+
# header
|
158
|
+
if !options['headerless']
|
159
|
+
header_height = 80
|
160
|
+
pdf.bounding_box([0, doc_height], :width => doc_width, :height => header_height) do
|
161
|
+
pdf.line_width = 2
|
162
|
+
pdf.font_size 16
|
163
|
+
pdf.fill_color "eeeeee"
|
164
|
+
pdf.stroke_color "888888"
|
165
|
+
include_back = options['pages'] && page_num != 1 && page_num != 0
|
166
|
+
# Go Back
|
167
|
+
if include_back
|
168
|
+
OBF::Utils.log " board backlinks #{obj['id']} #{options['backlinks'].to_json}"
|
169
|
+
options['backlinks'] ||= []
|
170
|
+
if options['backlinks'].length > 0
|
171
|
+
x = 110
|
172
|
+
pdf.fill_and_stroke_rounded_rectangle [x, header_height], 100, header_height, default_radius
|
173
|
+
pdf.fill_color "6D81D1"
|
174
|
+
pdf.fill_and_stroke_polygon([x + 5, 45], [x + 35, 70], [x + 35, 60], [x + 95, 60], [x + 95, 30], [x + 35, 30], [x + 35, 20])
|
175
|
+
pdf.fill_color "666666"
|
176
|
+
text_options = {:text => "Go Back"}
|
177
|
+
text_options[:anchor] = "page1" if options['links']
|
178
|
+
pdf.formatted_text_box [text_options], :at => [x + 10, header_height], :width => 80, :height => 80, :align => :center, :valign => :bottom, :overflow => :shrink_to_fit
|
179
|
+
backlinks = (options['backlinks'] || []).join(',')
|
180
|
+
pdf.fill_color "ffffff"
|
181
|
+
pdf.formatted_text_box [{:text => backlinks}], :at => [x + 20, header_height + 5 - 25], :width => 70, :height => 30, :align => :center, :valign => :center, :overflow => :shrink_to_fit
|
182
|
+
end
|
183
|
+
end
|
186
184
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
185
|
+
# Say it Out Loud
|
186
|
+
pdf.fill_color "ffffff"
|
187
|
+
shift = include_back ? 0 : 55
|
188
|
+
offset = include_back ? 110 : 55
|
189
|
+
box_shift = include_back ? 110 : 0
|
190
|
+
|
191
|
+
pdf.fill_and_stroke_rounded_rectangle [110 + box_shift, header_height], 170 + shift + shift, header_height, default_radius
|
192
|
+
pdf.fill_color "DDDB54"
|
193
|
+
pdf.fill_and_stroke do
|
194
|
+
pdf.move_to 160 + offset, 40
|
195
|
+
pdf.line_to 190 + offset, 55
|
196
|
+
pdf.curve_to [125 + offset, 40], :bounds => [[180 + offset, 80], [125 + offset, 80]]
|
197
|
+
pdf.curve_to [190 + offset, 25], :bounds => [[125 + offset, 0], [180 + offset, 0]]
|
198
|
+
pdf.line_to 160 + offset, 40
|
199
|
+
end
|
200
|
+
pdf.fill_color "444444"
|
201
|
+
pdf.text_box "Say that out loud for me", :at => [210 + offset, header_height], :width => 60, :height => 80, :align => :center, :valign => :center, :overflow => :shrink_to_fit
|
204
202
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
203
|
+
# Start Over
|
204
|
+
x = doc_width
|
205
|
+
pdf.fill_color "eeeeee"
|
206
|
+
pdf.fill_and_stroke_rounded_rectangle [(doc_width - x), header_height], 100, header_height, default_radius
|
207
|
+
pdf.fill_color "5c9c6d"
|
208
|
+
pdf.stroke_color "25783b"
|
209
|
+
pdf.fill_and_stroke_polygon([doc_width - x + 50, 75], [doc_width - x + 80, 50], [doc_width - x + 80, 20], [doc_width - x + 20, 20], [doc_width - x + 20, 50])
|
210
|
+
pdf.stroke_color "888888"
|
211
|
+
pdf.fill_color "666666"
|
212
|
+
pdf.text_box "Start Over", :styles => [:bold], :at => [(doc_width - x + 10), header_height], :width => 80, :height => 80, :align => :center, :valign => :bottom, :overflow => :shrink_to_fit
|
215
213
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
214
|
+
# Oops
|
215
|
+
x = 210
|
216
|
+
pdf.fill_color "eeeeee"
|
217
|
+
pdf.fill_and_stroke_rounded_rectangle [(doc_width - x), header_height], 100, header_height, default_radius
|
218
|
+
pdf.fill_color "6653a6"
|
219
|
+
pdf.stroke_color "554a78"
|
220
|
+
pdf.fill_and_stroke_polygon([doc_width - x + 50 - 7, 75], [doc_width - x + 50 + 7, 75], [doc_width - x + 50 + 7, 40], [doc_width - x + 50 - 7, 40])
|
221
|
+
pdf.fill_and_stroke_polygon([doc_width - x + 50 - 7, 33], [doc_width - x + 50 + 7, 33], [doc_width - x + 50 + 7, 20], [doc_width - x + 50 - 7, 20])
|
222
|
+
pdf.stroke_color "888888"
|
223
|
+
pdf.fill_color "666666"
|
224
|
+
pdf.text_box "Oops", :at => [(doc_width - x + 10), header_height], :width => 80, :height => 80, :align => :center, :valign => :bottom, :overflow => :shrink_to_fit
|
227
225
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
226
|
+
# Stop
|
227
|
+
x = 320
|
228
|
+
pdf.fill_color "eeeeee"
|
229
|
+
pdf.fill_and_stroke_rounded_rectangle [(doc_width - x), header_height], 100, header_height, default_radius
|
230
|
+
pdf.fill_color "944747"
|
231
|
+
pdf.stroke_color "693636"
|
232
|
+
pdf.fill_and_stroke_polygon([doc_width - x + 39, 70], [doc_width - x + 61, 70], [doc_width - x + 75, 56], [doc_width - x + 75, 34], [doc_width - x + 61, 20], [doc_width - x + 39, 20], [doc_width - x + 25, 34], [doc_width - x + 25, 56])
|
233
|
+
pdf.stroke_color "888888"
|
234
|
+
pdf.fill_color "666666"
|
235
|
+
pdf.text_box "Stop", :at => [(doc_width - x + 10), header_height], :width => 80, :height => 80, :align => :center, :valign => :bottom, :overflow => :shrink_to_fit
|
236
|
+
|
237
|
+
# Clear
|
238
|
+
x = 100
|
239
|
+
pdf.fill_color "eeeeee"
|
240
|
+
pdf.fill_and_stroke_rounded_rectangle [(doc_width - x), header_height], 100, header_height, default_radius
|
241
|
+
pdf.stroke_color "666666"
|
242
|
+
pdf.fill_color "888888"
|
243
|
+
pdf.fill_and_stroke_polygon([doc_width - x + 10, 45], [doc_width - x + 35, 70], [doc_width - x + 90, 70], [doc_width - x + 90, 20], [doc_width - x + 35, 20])
|
244
|
+
pdf.stroke_color "888888"
|
245
|
+
pdf.fill_color "666666"
|
246
|
+
pdf.text_box "Clear", :at => [(doc_width - x + 10), header_height], :width => 80, :height => 80, :align => :center, :valign => :bottom, :overflow => :shrink_to_fit
|
247
|
+
end
|
248
|
+
end
|
249
|
+
# footer
|
250
|
+
pdf.fill_color "bbbbbb"
|
251
|
+
obj['name'] = nil if obj['name'] == 'Unnamed Board'
|
252
|
+
if OBF::PDF.footer_text || obj['name']
|
253
|
+
text = [obj['name'], OBF::PDF.footer_text].compact.join(', ')
|
254
|
+
offset = options['pages'] ? 400 : 300
|
255
|
+
pdf.formatted_text_box [{:text => text, :link => OBF::PDF.footer_url}], :at => [doc_width - offset, text_height], :width => 300, :height => text_height, :align => :right, :valign => :center, :overflow => :shrink_to_fit
|
256
|
+
end
|
257
|
+
pdf.fill_color "000000"
|
258
|
+
if options['pages'] && page_num != 0
|
259
|
+
text_options = {:text => page_num.to_s}
|
260
|
+
text_options[:anchor] = "page1" if options['links']
|
261
|
+
pdf.formatted_text_box [text_options], :at => [doc_width - 100, text_height], :width => 100, :height => text_height, :align => :right, :valign => :center, :overflow => :shrink_to_fit
|
249
262
|
end
|
250
263
|
end
|
251
264
|
|
@@ -413,22 +426,6 @@ module OBF::PDF
|
|
413
426
|
end
|
414
427
|
end
|
415
428
|
end
|
416
|
-
|
417
|
-
# footer
|
418
|
-
pdf.fill_color "bbbbbb"
|
419
|
-
obj['name'] = nil if obj['name'] == 'Unnamed Board'
|
420
|
-
pdf.font('Arial')
|
421
|
-
if OBF::PDF.footer_text || obj['name']
|
422
|
-
text = [obj['name'], OBF::PDF.footer_text].compact.join(', ')
|
423
|
-
offset = options['pages'] ? 400 : 300
|
424
|
-
pdf.formatted_text_box [{:text => text, :link => OBF::PDF.footer_url}], :at => [doc_width - offset, text_height], :width => 300, :height => text_height, :align => :right, :valign => :center, :overflow => :shrink_to_fit
|
425
|
-
end
|
426
|
-
pdf.fill_color "000000"
|
427
|
-
if options['pages'] && page_num != 0
|
428
|
-
text_options = {:text => page_num.to_s}
|
429
|
-
text_options[:anchor] = "page1" if options['links']
|
430
|
-
pdf.formatted_text_box [text_options], :at => [doc_width - 100, text_height], :width => 100, :height => text_height, :align => :right, :valign => :center, :overflow => :shrink_to_fit
|
431
|
-
end
|
432
429
|
end
|
433
430
|
end
|
434
431
|
|