pdf_writing_tools 0.0.10 → 0.0.11

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 +61 -0
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32f9690ccbc09db00ba94daceb4d34c0f565bb73f3229c3712a00886aa5cce5d
4
- data.tar.gz: 41ed383e3b7ee71992f56b7ced2425902f3a51cb947181220a883f1b720a32ea
3
+ metadata.gz: 45529182709a12f3e41c914f9cdd36583589ca618570fe2f7b8fcdae6fe24305
4
+ data.tar.gz: a594ff7382a41a60c07f540d4d77656be8221b6d2429d52e8237593bfa86d742
5
5
  SHA512:
6
- metadata.gz: de956cc911e9cf7ee357ccaa4d35354b0c89893aa8522004c992ebb223b17f3dfb864d9e92aeda7160c8cb3838c254ae346c87108d975d11b1787487cf5077e8
7
- data.tar.gz: ed74125384c0f30f6e5bfa33520672ae6039cb2cdb05b0be4a6f5250145b02d3e8265332bbc134fc34d8b78d018212c9b386ec26ad803a3a8f2e95ca984fc6e6
6
+ metadata.gz: 597f10537e24f2b42318e5471a8ddd0222bd16789c044fbd6a47aeb0ab8b226557f534cd84c9104dffbdf460dd53df5f136faef3801d28c9d1ee8e58f5f2dc82
7
+ data.tar.gz: 4c6dd9d236317f5d65e51c8557e4dd1d93ae301aa856fea195d45090c07829c4457e85f6fbd4a11509ad5a87acd969ee82f93ce451d201e6ea24aa4eb2ac6954
@@ -32,4 +32,65 @@ module PdfWritingTools
32
32
  end
33
33
  actions_list
34
34
  end
35
+
36
+
37
+ ######## Disegna una cella di dimensioni fissate, nella data posizione. ######
38
+ # E' Possibile indicare il colore del bordo, dello sfondo, del font e della
39
+ # relativa dimensione (oltre a tutta un'altra serie di parametri (opts), vedere prima
40
+ # parte della funzione)
41
+ # La cella, viene disegnata "globalmente", rispetto al pdf, ossia NON relativamente
42
+ # ad altri contenitori.
43
+ # x e y, indicano rispettivamente le coordinate x e y del vertice in alto a
44
+ # sinistra del box.
45
+ # Il vertice è relativo al margine superiore del pdf, contrariamente a quanto
46
+ # accade quando si utilizzano le primitive prawn (dove il margine di riferimento è
47
+ # quello basso della pagina).
48
+ # Bisogna pertanto prestare attenzione quando si mischiano primitive prawn
49
+ # con queste funzioni.
50
+ def self.draw_cell_fixed_height(pdf, x, y, w, h, t, opts={})
51
+ font_size = opts[:font_size] || 10
52
+ style = opts[:style] || :normal
53
+ align = opts[:align] || :left
54
+ valign = opts[:valign] || :top
55
+ font_color = opts[:font_color] || '000000'
56
+ border_color = opts[:border_color] || '000000'
57
+ background_color = opts[:background_color] || 'FFFFFF'
58
+ left_padding = opts[:left_padding] || 5
59
+ right_padding = opts[:right_padding] || 5
60
+ top_padding = opts[:top_padding] || 5
61
+ bottom_padding = opts[:bottom_padding] || 5
62
+ pdf_height = opts[:pdf_height] || 297.mm
63
+ pdf_width = opts[:pdf_width] || 21.cm
64
+
65
+ result = ''
66
+
67
+ pdf.canvas do
68
+ pdf.line_width = 0.5
69
+
70
+ # Colore di sfondo della cella
71
+ pdf.fill_color(background_color)
72
+
73
+ # Disegna lo sfondo della cella
74
+ pdf.fill_rectangle([x, pdf_height - y], w, h)
75
+
76
+ pdf.stroke_color border_color
77
+ pdf.stroke_rectangle([x, pdf_height - y], w, h)
78
+
79
+ # Colore del testo nella cella
80
+ pdf.fill_color(font_color)
81
+ # Disegno il testo contenuto nella cella
82
+ result = pdf.text_box(
83
+ t,
84
+ at: [x + left_padding, pdf_height - y - top_padding],
85
+ width: w - left_padding - right_padding,
86
+ height: h - top_padding - bottom_padding,
87
+ size: font_size,
88
+ style: style,
89
+ align: align,
90
+ valign: valign
91
+ )
92
+ end
93
+
94
+ result
95
+ end
35
96
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdf_writing_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - JSalvo1978