pdf_writing_tools 0.0.18 → 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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pdf_writing_tools.rb +32 -19
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '01850947c8686b987899d011697d5796c94ba7b3c3edd47dd95e77b1edf83437'
4
- data.tar.gz: bbc70c15e5bb7368342bcd81d2091cae811738abfb3ac5d8226dfc3814949656
3
+ metadata.gz: b86239df8011a50e9180eac3b9e61ca5dd3d479cfcda975c027bed0f920b8517
4
+ data.tar.gz: f747087dfd3a4a483fb5611758d7b4501eb6377ac9ab04f9f3d5b11c4851553d
5
5
  SHA512:
6
- metadata.gz: a59da430b55240d7757a8f0fcd9eebc7d30be53562fea63e857e7782b8ad5db0e98f7a28824ec3d95a1749c0d68bfe489e1c47b341f317fdecd410c4d8ee8cf8
7
- data.tar.gz: 0e84e64bf4f74aa40a209261f1c6dddc1c1bf8726a647938744c1997e5f1d0f769af97977aa7d1d4a63d6bae835aadcee5de7044fc27a10f5fd807a7cfcb5cf9
6
+ metadata.gz: 8d6750a12aaab5b59806a12f2150cf137483d0b0cb6398244584020ab56379492e1db7ff04d5fc53ee19e396ae10b02c0fd92443f207f02e1a2cd54bdb1b2864
7
+ data.tar.gz: e466eecd65361c97f79254caf2ed651e499986c62538e89c53b7675ba9ceb33838b811d7318e96c17f0d9511f1f63f8d5e3f0858d54c7251f66c3f1ec76ba363
@@ -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
- widths.each_with_index do |width, i|
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
- r = draw_cell_auto_height(pdf, draw_simulation = true, x+offset, y, width, texts[i], cell_opts, auto_y)
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
- offset += width
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
- # ricalcolo l'altezza di riga per non superare tale margine
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
- # Se nei testi residui, sono presenti solo stringhe vuote, posso uscire dal
357
- # loop, altrimenti, devo cambiare pagina e disegnare una nuova riga con i
358
- # testi rimanenti
359
- if !check_no_empty_string_presence(texts)
360
- new_y = y + max_cell_height
361
- break
362
- else
363
- pdf.start_new_page
364
- y = pdf_margin_top # Posiziono il cursore ad inizio della nuova pagina
365
- 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
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.18
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-06 00:00:00.000000000 Z
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: