pdf_writing_tools 0.0.17 → 0.0.19

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 +31 -14
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfd07499bdd57bee5a8827e5117da0d0b62626cfb33eeacdd8bbc4cc87d0c6f2
4
- data.tar.gz: d213573292a9c3ca25b58670d4b59b3477a0efe3ba9123f24d36f58b1f9e1c43
3
+ metadata.gz: 5c9eda846aa608aa060dfcdf248785641d8157fd11a6854ca7bb28190ecff249
4
+ data.tar.gz: '09d6d26696ae73858b17c6cd41a5b228e021f661d9d8d6c8182be07b0dbe3ea9'
5
5
  SHA512:
6
- metadata.gz: 781320879aeecc90bc789072d63b7628edbc46b343427bb4841f2e3d40c3c7517116e7041fb7d7b61d7e498d576c2f80687389416ead2fa09e2f8dd88de4619f
7
- data.tar.gz: 77753b05230983e1b88b8627f257e8cb8d27a12267578a4987e560da9e606cd74ae3c67f3167e3b578e4c1beda1a1db9d7c024684865cdac8d9cabe003e009f9
6
+ metadata.gz: 3b3ee0196bc304ad36c7b4c08af7083b6a9b92a786b3f1a5dd500dae85278362c875822fdddb13950d232d3ba2af35794bb4491b9cdf83deb732736f523912ba
7
+ data.tar.gz: 3f315a5b62258ebdb244d4b7da40135047932a5626ec2401ddcf5bb4b24e5ad74b5104fdba7909498695e2681743cd65f27792526ebbd9b3c636ff75987a9379
@@ -137,6 +137,10 @@ module PdfWritingTools
137
137
 
138
138
 
139
139
  result = 0
140
+
141
+ # Il testo in modalità simulazione, verrà generato in posizione y_pos1, tenendo conto del padding.
142
+ # In questo modo, quando andrò a disegnare la cella vera e propria in posizione y_pos2, il testo
143
+ # avrà il suo "spazio" (padding)
140
144
  y_pos1 = auto_y ? (pdf.cursor - top_padding) : (pdf_height - y - top_padding)
141
145
  y_pos2 = auto_y ? pdf.cursor : (pdf_height - y)
142
146
 
@@ -173,7 +177,6 @@ module PdfWritingTools
173
177
  pdf.stroke_color(border_color) # Colore del bordo
174
178
 
175
179
 
176
-
177
180
  if no_background
178
181
  else
179
182
  pdf.fill_and_stroke_rectangle([x, y_pos2], (w + left_padding + right_padding), (h+top_padding+bottom_padding))
@@ -259,10 +262,10 @@ module PdfWritingTools
259
262
  pdf_margin_right = opts[:pdf_margin_right] || 2.cm
260
263
 
261
264
  new_y = pdf_margin_top
262
- pdf.y = pdf.y + y
263
265
 
264
- loop do
266
+ overflowed = false
265
267
 
268
+ loop do
266
269
  max_cell_height = 0
267
270
 
268
271
  # 1 - Cerco l'altezza della riga
@@ -297,6 +300,11 @@ module PdfWritingTools
297
300
 
298
301
  r = draw_cell_auto_height(pdf, draw_simulation = true, x+offset, y, width, texts[i], cell_opts, auto_y)
299
302
 
303
+ if r[:overflow] && r[:overflow] == ""
304
+ overflowed = true
305
+ end
306
+
307
+
300
308
  if r[:height] > max_cell_height
301
309
  max_cell_height = r[:height]
302
310
  end
@@ -307,9 +315,16 @@ module PdfWritingTools
307
315
  # Non voglio che la riga ecceda il margine di pagina, quindi se così fosse
308
316
  # ricalcolo l'altezza di riga per non superare tale margine
309
317
  if y + max_cell_height > pdf_height - pdf_margin_bottom
310
- max_cell_height = pdf_height - pdf_margin_bottom - y
318
+ overflowed = true
319
+ #max_cell_height = pdf_height - pdf_margin_bottom - y
311
320
  end
312
321
 
322
+
323
+ if overflowed
324
+ pdf.start_new_page
325
+ y = pdf_margin_top # Posiziono il cursore ad inizio della nuova pagina
326
+ end
327
+
313
328
  # A seguito della simulazione, ho ottenuto l'altezza di riga...
314
329
  # ... ora passo al disegno vero e proprie delle celle...
315
330
  offset = 0
@@ -352,16 +367,18 @@ module PdfWritingTools
352
367
 
353
368
  texts = rtexts
354
369
 
355
- # Se nei testi residui, sono presenti solo stringhe vuote, posso uscire dal
356
- # loop, altrimenti, devo cambiare pagina e disegnare una nuova riga con i
357
- # testi rimanenti
358
- if !check_no_empty_string_presence(texts)
359
- new_y = y + max_cell_height
360
- break
361
- else
362
- pdf.start_new_page
363
- y = pdf_margin_top # Posiziono il cursore ad inizio della nuova pagina
364
- end
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
381
+ end
365
382
  end
366
383
 
367
384
  pdf.y = (pdf_height - 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.17
4
+ version: 0.0.19
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-05 00:00:00.000000000 Z
11
+ date: 2024-01-08 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: