pdf_writing_tools 0.0.19 → 0.0.20
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/lib/pdf_writing_tools.rb +28 -31
- 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,7 +261,13 @@ module PdfWritingTools
|
|
263
261
|
|
264
262
|
new_y = pdf_margin_top
|
265
263
|
|
266
|
-
|
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
|
267
271
|
|
268
272
|
loop do
|
269
273
|
max_cell_height = 0
|
@@ -273,7 +277,7 @@ module PdfWritingTools
|
|
273
277
|
# In questo modo, posso sapere quale sarà la massima altezza raggiunta da una
|
274
278
|
# cella, ossia l'altezza che deve avere la riga
|
275
279
|
offset = 0
|
276
|
-
|
280
|
+
widths.each_with_index do |width, i|
|
277
281
|
font_size = font_sizes[i] || font_sizes[0]
|
278
282
|
style = styles[i] || styles[0]
|
279
283
|
align = alignments[i] || alignments[0]
|
@@ -298,32 +302,25 @@ module PdfWritingTools
|
|
298
302
|
cell_opts[:pdf_height] = 297.mm
|
299
303
|
cell_opts[:pdf_weigth] = 21.cm
|
300
304
|
|
301
|
-
|
302
|
-
|
303
|
-
if r[:overflow] && r[:overflow] == ""
|
304
|
-
overflowed = true
|
305
|
-
end
|
305
|
+
draw_simulation = true
|
306
|
+
r = draw_cell_auto_height(pdf, draw_simulation, x+offset, y, width, texts[i], cell_opts, auto_y)
|
306
307
|
|
307
308
|
|
308
309
|
if r[:height] > max_cell_height
|
309
310
|
max_cell_height = r[:height]
|
310
311
|
end
|
311
312
|
|
312
|
-
|
313
|
+
offset += width
|
313
314
|
end
|
314
315
|
|
316
|
+
|
315
317
|
# Non voglio che la riga ecceda il margine di pagina, quindi se così fosse
|
316
|
-
#
|
317
|
-
if y + max_cell_height > pdf_height - pdf_margin_bottom
|
318
|
-
overflowed = true
|
318
|
+
# cambio pagina
|
319
|
+
if (y + max_cell_height) > (pdf_height - pdf_margin_bottom)
|
319
320
|
#max_cell_height = pdf_height - pdf_margin_bottom - y
|
320
|
-
end
|
321
|
-
|
322
|
-
|
323
|
-
if overflowed
|
324
321
|
pdf.start_new_page
|
325
|
-
y = pdf_margin_top
|
326
|
-
|
322
|
+
y = pdf_margin_top
|
323
|
+
end
|
327
324
|
|
328
325
|
# A seguito della simulazione, ho ottenuto l'altezza di riga...
|
329
326
|
# ... ora passo al disegno vero e proprie delle celle...
|
@@ -367,20 +364,20 @@ module PdfWritingTools
|
|
367
364
|
|
368
365
|
texts = rtexts
|
369
366
|
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
y = pdf_margin_top # Posiziono il cursore ad inizio della nuova pagina
|
380
|
-
end
|
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
|
381
376
|
end
|
382
377
|
end
|
383
378
|
|
379
|
+
|
380
|
+
|
384
381
|
pdf.y = (pdf_height - new_y)
|
385
382
|
|
386
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:
|