pdf_writing_tools 0.0.19 → 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pdf_writing_tools.rb +28 -31
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c9eda846aa608aa060dfcdf248785641d8157fd11a6854ca7bb28190ecff249
4
- data.tar.gz: '09d6d26696ae73858b17c6cd41a5b228e021f661d9d8d6c8182be07b0dbe3ea9'
3
+ metadata.gz: b86239df8011a50e9180eac3b9e61ca5dd3d479cfcda975c027bed0f920b8517
4
+ data.tar.gz: f747087dfd3a4a483fb5611758d7b4501eb6377ac9ab04f9f3d5b11c4851553d
5
5
  SHA512:
6
- metadata.gz: 3b3ee0196bc304ad36c7b4c08af7083b6a9b92a786b3f1a5dd500dae85278362c875822fdddb13950d232d3ba2af35794bb4491b9cdf83deb732736f523912ba
7
- data.tar.gz: 3f315a5b62258ebdb244d4b7da40135047932a5626ec2401ddcf5bb4b24e5ad74b5104fdba7909498695e2681743cd65f27792526ebbd9b3c636ff75987a9379
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,7 +261,13 @@ module PdfWritingTools
263
261
 
264
262
  new_y = pdf_margin_top
265
263
 
266
- overflowed = false
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
- widths.each_with_index do |width, i|
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
- r = draw_cell_auto_height(pdf, draw_simulation = true, x+offset, y, width, texts[i], cell_opts, auto_y)
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
- offset += width
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
- # ricalcolo l'altezza di riga per non superare tale margine
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 # Posiziono il cursore ad inizio della nuova pagina
326
- end
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
- if false
371
- # Se nei testi residui, sono presenti solo stringhe vuote, posso uscire dal
372
- # loop, altrimenti, devo cambiare pagina e disegnare una nuova riga con i
373
- # testi rimanenti
374
- if !check_no_empty_string_presence(texts)
375
- new_y = y + max_cell_height
376
- break
377
- else
378
- pdf.start_new_page
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.19
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-08 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: