pdf_writing_tools 0.0.18 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pdf_writing_tools.rb +32 -19
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b86239df8011a50e9180eac3b9e61ca5dd3d479cfcda975c027bed0f920b8517
|
4
|
+
data.tar.gz: f747087dfd3a4a483fb5611758d7b4501eb6377ac9ab04f9f3d5b11c4851553d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d6750a12aaab5b59806a12f2150cf137483d0b0cb6398244584020ab56379492e1db7ff04d5fc53ee19e396ae10b02c0fd92443f207f02e1a2cd54bdb1b2864
|
7
|
+
data.tar.gz: e466eecd65361c97f79254caf2ed651e499986c62538e89c53b7675ba9ceb33838b811d7318e96c17f0d9511f1f63f8d5e3f0858d54c7251f66c3f1ec76ba363
|
data/lib/pdf_writing_tools.rb
CHANGED
@@ -183,9 +183,7 @@ module PdfWritingTools
|
|
183
183
|
end
|
184
184
|
# ... e infine, sopra lo sfondo disegno il testo
|
185
185
|
pdf.fill_color(font_color) # colore del testo
|
186
|
-
text_overflow = b.render()
|
187
|
-
|
188
|
-
# text_overflow è l'eventuale testo avanzato
|
186
|
+
text_overflow = b.render() # text_overflow è l'eventuale testo avanzato
|
189
187
|
end
|
190
188
|
|
191
189
|
# La cella potrebbe non riuscire ad espandersi a sufficienza (troppo vicina al
|
@@ -263,6 +261,14 @@ module PdfWritingTools
|
|
263
261
|
|
264
262
|
new_y = pdf_margin_top
|
265
263
|
|
264
|
+
|
265
|
+
# Se la y della nuova riga (angolo superiore sinistro), esce dal margine di pagina,
|
266
|
+
# non posso disegnare la riga in questa pagina, ma devo passare alla successiva
|
267
|
+
if (y) > (pdf_height - pdf_margin_bottom)
|
268
|
+
pdf.start_new_page
|
269
|
+
y = pdf_margin_top
|
270
|
+
end
|
271
|
+
|
266
272
|
loop do
|
267
273
|
max_cell_height = 0
|
268
274
|
|
@@ -271,7 +277,7 @@ module PdfWritingTools
|
|
271
277
|
# In questo modo, posso sapere quale sarà la massima altezza raggiunta da una
|
272
278
|
# cella, ossia l'altezza che deve avere la riga
|
273
279
|
offset = 0
|
274
|
-
|
280
|
+
widths.each_with_index do |width, i|
|
275
281
|
font_size = font_sizes[i] || font_sizes[0]
|
276
282
|
style = styles[i] || styles[0]
|
277
283
|
align = alignments[i] || alignments[0]
|
@@ -296,19 +302,24 @@ module PdfWritingTools
|
|
296
302
|
cell_opts[:pdf_height] = 297.mm
|
297
303
|
cell_opts[:pdf_weigth] = 21.cm
|
298
304
|
|
299
|
-
|
305
|
+
draw_simulation = true
|
306
|
+
r = draw_cell_auto_height(pdf, draw_simulation, x+offset, y, width, texts[i], cell_opts, auto_y)
|
307
|
+
|
300
308
|
|
301
309
|
if r[:height] > max_cell_height
|
302
310
|
max_cell_height = r[:height]
|
303
311
|
end
|
304
312
|
|
305
|
-
|
313
|
+
offset += width
|
306
314
|
end
|
307
315
|
|
316
|
+
|
308
317
|
# Non voglio che la riga ecceda il margine di pagina, quindi se così fosse
|
309
|
-
#
|
310
|
-
if y + max_cell_height > pdf_height - pdf_margin_bottom
|
311
|
-
max_cell_height = pdf_height - pdf_margin_bottom - y
|
318
|
+
# cambio pagina
|
319
|
+
if (y + max_cell_height) > (pdf_height - pdf_margin_bottom)
|
320
|
+
#max_cell_height = pdf_height - pdf_margin_bottom - y
|
321
|
+
pdf.start_new_page
|
322
|
+
y = pdf_margin_top
|
312
323
|
end
|
313
324
|
|
314
325
|
# A seguito della simulazione, ho ottenuto l'altezza di riga...
|
@@ -353,18 +364,20 @@ module PdfWritingTools
|
|
353
364
|
|
354
365
|
texts = rtexts
|
355
366
|
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
367
|
+
# Se nei testi residui, sono presenti solo stringhe vuote, posso uscire dal
|
368
|
+
# loop, altrimenti, devo cambiare pagina e disegnare una nuova riga con i
|
369
|
+
# testi rimanenti
|
370
|
+
if !check_no_empty_string_presence(texts)
|
371
|
+
new_y = y + max_cell_height
|
372
|
+
break
|
373
|
+
else
|
374
|
+
pdf.start_new_page
|
375
|
+
y = pdf_margin_top # Posiziono il cursore ad inizio della nuova pagina
|
376
|
+
end
|
366
377
|
end
|
367
378
|
|
379
|
+
|
380
|
+
|
368
381
|
pdf.y = (pdf_height - new_y)
|
369
382
|
|
370
383
|
return new_y
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdf_writing_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JSalvo1978
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Plugin for write pdf in a simplified manner, using prawn as backend
|
14
14
|
email:
|