ruby_danfe 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ruby_danfe.rb +447 -436
- data/ruby_danfe.gemspec +1 -1
- metadata +3 -3
data/lib/ruby_danfe.rb
CHANGED
@@ -4,665 +4,676 @@ require 'nokogiri'
|
|
4
4
|
|
5
5
|
module RubyDanfe
|
6
6
|
|
7
|
-
version = "0.0.
|
7
|
+
version = "0.0.3"
|
8
8
|
|
9
9
|
class XML
|
10
|
-
def initialize(
|
11
|
-
@xml = Nokogiri::XML(
|
10
|
+
def initialize(xml)
|
11
|
+
@xml = Nokogiri::XML(xml)
|
12
12
|
end
|
13
13
|
def [](xpath)
|
14
14
|
node = @xml.css(xpath)
|
15
15
|
return node ? node.text : ''
|
16
16
|
end
|
17
17
|
end
|
18
|
-
|
19
|
-
def self.generate(pdf_filename, xml_filename)
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
Prawn::Document.
|
19
|
+
def self.generatePDFFromXML(xml)
|
20
|
+
|
21
|
+
pdf = Prawn::Document.new
|
24
22
|
|
25
|
-
|
26
|
-
|
23
|
+
# rectangle
|
24
|
+
pdf.stroke_rectangle [328, 653], 222, 22
|
27
25
|
|
28
|
-
|
29
|
-
|
26
|
+
# rectangle
|
27
|
+
pdf.stroke_rectangle [328, 697], 222, 84
|
30
28
|
|
31
|
-
|
32
|
-
|
29
|
+
# rectangle
|
30
|
+
pdf.stroke_rectangle [347, 457], 96, 18
|
33
31
|
|
34
|
-
|
35
|
-
|
32
|
+
# rectangle
|
33
|
+
pdf.stroke_rectangle [443, 749], 107, 37
|
36
34
|
|
37
|
-
|
38
|
-
|
35
|
+
# rectangle
|
36
|
+
pdf.stroke_rectangle [112, 526], 63, 44
|
39
37
|
|
40
|
-
|
41
|
-
|
38
|
+
# rectangle
|
39
|
+
pdf.stroke_rectangle [49, 526], 63, 44
|
42
40
|
|
43
|
-
|
44
|
-
|
41
|
+
# rectangle
|
42
|
+
pdf.stroke_rectangle [-14, 526], 63, 44
|
45
43
|
|
46
|
-
|
47
|
-
|
44
|
+
# rectangle
|
45
|
+
pdf.stroke_rectangle [429, 431], 24, 18
|
48
46
|
|
49
|
-
|
50
|
-
|
47
|
+
# rectangle
|
48
|
+
|
49
|
+
pdf.stroke_rectangle [165, 431], 59, 18
|
51
50
|
|
52
|
-
|
53
|
-
|
51
|
+
# rectangle
|
52
|
+
pdf.stroke_rectangle [213, 424], 9, 9
|
54
53
|
|
55
|
-
|
56
|
-
|
54
|
+
# rectangle
|
55
|
+
pdf.stroke_rectangle [364, 613], 186, 18
|
57
56
|
|
58
|
-
|
59
|
-
|
57
|
+
# rectangle
|
58
|
+
pdf.stroke_rectangle [175, 613], 189, 18
|
60
59
|
|
61
|
-
|
62
|
-
|
60
|
+
# rectangle
|
61
|
+
pdf.stroke_rectangle [328, 673], 222, 18
|
63
62
|
|
64
|
-
|
65
|
-
|
63
|
+
# rectangle
|
64
|
+
pdf.stroke_rectangle [328, 697], 222, 24
|
66
65
|
|
67
|
-
|
68
|
-
|
66
|
+
# rectangle
|
67
|
+
pdf.stroke_rectangle [264, 697], 64, 66
|
69
68
|
|
70
|
-
|
71
|
-
|
69
|
+
# rectangle
|
70
|
+
pdf.stroke_rectangle [312, 668], 9, 10
|
72
71
|
|
73
|
-
|
74
|
-
|
72
|
+
# rectangle
|
73
|
+
pdf.stroke_rectangle [-14, 431], 179, 18
|
75
74
|
|
76
|
-
|
77
|
-
|
75
|
+
# rectangle
|
76
|
+
pdf.stroke_rectangle [-14, 475], 134, 18
|
78
77
|
|
79
|
-
|
80
|
-
|
78
|
+
# rectangle
|
79
|
+
pdf.stroke_rectangle [-14, 457], 91, 18
|
81
80
|
|
82
|
-
|
83
|
-
|
81
|
+
# rectangle
|
82
|
+
pdf.stroke_rectangle [-14, 587], 373, 20
|
84
83
|
|
85
|
-
|
86
|
-
|
84
|
+
# rectangle
|
85
|
+
pdf.stroke_rectangle [224, 431], 75, 18
|
87
86
|
|
88
|
-
|
89
|
-
|
87
|
+
# rectangle
|
88
|
+
pdf.stroke_rectangle [119, 475], 115, 18
|
90
89
|
|
91
|
-
|
92
|
-
|
90
|
+
# rectangle
|
91
|
+
pdf.stroke_rectangle [233, 475], 115, 18
|
93
92
|
|
94
|
-
|
95
|
-
|
93
|
+
# rectangle
|
94
|
+
pdf.stroke_rectangle [347, 475], 97, 18
|
96
95
|
|
97
|
-
|
98
|
-
|
96
|
+
# rectangle
|
97
|
+
pdf.stroke_rectangle [443, 475], 107, 18
|
99
98
|
|
100
|
-
|
101
|
-
|
99
|
+
# rectangle
|
100
|
+
pdf.stroke_rectangle [-14, 568], 305, 18
|
102
101
|
|
103
|
-
|
104
|
-
|
102
|
+
# rectangle
|
103
|
+
pdf.stroke_rectangle [471, 587], 79, 20
|
105
104
|
|
106
|
-
|
107
|
-
|
105
|
+
# rectangle
|
106
|
+
pdf.stroke_rectangle [358, 587], 113, 20
|
108
107
|
|
109
|
-
|
110
|
-
|
108
|
+
# rectangle
|
109
|
+
pdf.stroke_rectangle [290, 568], 125, 18
|
111
110
|
|
112
|
-
|
113
|
-
|
111
|
+
# rectangle
|
112
|
+
pdf.stroke_rectangle [414, 568], 57, 18
|
114
113
|
|
115
|
-
|
116
|
-
|
114
|
+
# rectangle
|
115
|
+
pdf.stroke_rectangle [213, 551], 111, 18
|
117
116
|
|
118
|
-
|
119
|
-
|
117
|
+
# rectangle
|
118
|
+
pdf.stroke_rectangle [323, 551], 32, 18
|
120
119
|
|
121
|
-
|
122
|
-
|
120
|
+
# rectangle
|
121
|
+
pdf.stroke_rectangle [471, 568], 79, 18
|
123
122
|
|
124
|
-
|
125
|
-
|
123
|
+
# rectangle
|
124
|
+
pdf.stroke_rectangle [471, 551], 79, 18
|
126
125
|
|
127
|
-
|
128
|
-
|
126
|
+
# rectangle
|
127
|
+
pdf.stroke_rectangle [354, 551], 117, 18
|
129
128
|
|
130
|
-
|
131
|
-
|
129
|
+
# rectangle
|
130
|
+
pdf.stroke_rectangle [-14, 551], 228, 18
|
132
131
|
|
133
|
-
|
134
|
-
|
132
|
+
# rectangle
|
133
|
+
pdf.stroke_rectangle [255, 457], 92, 18
|
135
134
|
|
136
|
-
|
137
|
-
|
135
|
+
# rectangle
|
136
|
+
pdf.stroke_rectangle [76, 457], 90, 18
|
138
137
|
|
139
|
-
|
140
|
-
|
138
|
+
# rectangle
|
139
|
+
pdf.stroke_rectangle [165, 457], 90, 18
|
141
140
|
|
142
|
-
|
143
|
-
|
141
|
+
# rectangle
|
142
|
+
pdf.stroke_rectangle [443, 457], 107, 18
|
144
143
|
|
145
|
-
|
146
|
-
|
144
|
+
# rectangle
|
145
|
+
pdf.stroke_rectangle [298, 431], 131, 18
|
147
146
|
|
148
|
-
|
149
|
-
|
147
|
+
# rectangle
|
148
|
+
pdf.stroke_rectangle [245, 413], 185, 18
|
150
149
|
|
151
|
-
|
152
|
-
|
150
|
+
# rectangle
|
151
|
+
pdf.stroke_rectangle [453, 431], 97, 18
|
153
152
|
|
154
|
-
|
155
|
-
|
153
|
+
# rectangle
|
154
|
+
pdf.stroke_rectangle [-14, 413], 260, 18
|
156
155
|
|
157
|
-
|
158
|
-
|
156
|
+
# rectangle
|
157
|
+
pdf.stroke_rectangle [-14, 395], 67, 18
|
159
158
|
|
160
|
-
|
161
|
-
|
159
|
+
# rectangle
|
160
|
+
pdf.stroke_rectangle [53, 395], 117, 18
|
162
161
|
|
163
|
-
|
164
|
-
|
162
|
+
# rectangle
|
163
|
+
pdf.stroke_rectangle [170, 395], 107, 18
|
165
164
|
|
166
|
-
|
167
|
-
|
165
|
+
# rectangle
|
166
|
+
pdf.stroke_rectangle [277, 395], 109, 18
|
168
167
|
|
169
|
-
|
170
|
-
|
168
|
+
# rectangle
|
169
|
+
pdf.stroke_rectangle [429, 413], 24, 18
|
171
170
|
|
172
|
-
|
173
|
-
|
171
|
+
# rectangle
|
172
|
+
pdf.stroke_rectangle [453, 413], 97, 18
|
174
173
|
|
175
|
-
|
176
|
-
|
174
|
+
# rectangle
|
175
|
+
pdf.stroke_rectangle [386, 395], 81, 18
|
177
176
|
|
178
|
-
|
179
|
-
|
177
|
+
# rectangle
|
178
|
+
pdf.stroke_rectangle [467, 395], 83, 18
|
180
179
|
|
181
|
-
|
182
|
-
|
180
|
+
# rectangle
|
181
|
+
pdf.stroke_rectangle [-14, 631], 342, 18
|
183
182
|
|
184
|
-
|
185
|
-
|
183
|
+
# rectangle
|
184
|
+
pdf.stroke_rectangle [-14, 613], 189, 18
|
186
185
|
|
187
|
-
|
188
|
-
|
186
|
+
# rectangle
|
187
|
+
pdf.stroke_rectangle [-14, 749], 457, 20
|
189
188
|
|
190
|
-
|
191
|
-
|
189
|
+
# rectangle
|
190
|
+
pdf.stroke_rectangle [-14, 729], 74, 17
|
192
191
|
|
193
|
-
|
194
|
-
|
192
|
+
# rectangle
|
193
|
+
pdf.stroke_rectangle [60, 729], 383, 17
|
195
194
|
|
196
|
-
|
197
|
-
|
195
|
+
# rectangle
|
196
|
+
pdf.stroke_rectangle [175, 526], 63, 44
|
198
197
|
|
199
|
-
|
200
|
-
|
198
|
+
# rectangle
|
199
|
+
pdf.stroke_rectangle [238, 526], 63, 44
|
201
200
|
|
202
|
-
|
203
|
-
|
201
|
+
# rectangle
|
202
|
+
pdf.stroke_rectangle [301, 526], 63, 44
|
204
203
|
|
205
|
-
|
206
|
-
|
204
|
+
# rectangle
|
205
|
+
pdf.stroke_rectangle [364, 526], 63, 44
|
207
206
|
|
208
|
-
|
209
|
-
|
207
|
+
# rectangle
|
208
|
+
pdf.stroke_rectangle [427, 526], 63, 44
|
210
209
|
|
211
|
-
|
212
|
-
|
210
|
+
# rectangle
|
211
|
+
pdf.stroke_rectangle [490, 526], 60, 44
|
213
212
|
|
214
|
-
|
215
|
-
|
213
|
+
# rectangle
|
214
|
+
pdf.stroke_rectangle [-14, 367], 564, 213
|
216
215
|
|
217
|
-
|
218
|
-
|
216
|
+
# rectangle
|
217
|
+
pdf.stroke_rectangle [-14, 117], 341, 173
|
219
218
|
|
220
|
-
|
221
|
-
|
219
|
+
# rectangle
|
220
|
+
pdf.stroke_rectangle [327, 117], 223, 173
|
222
221
|
|
223
|
-
|
224
|
-
|
222
|
+
# rectangle
|
223
|
+
pdf.stroke_rectangle [-14, 146], 112, 20
|
225
224
|
|
226
|
-
|
227
|
-
|
225
|
+
# rectangle
|
226
|
+
pdf.stroke_rectangle [97, 146], 145, 20
|
228
227
|
|
229
|
-
|
230
|
-
|
228
|
+
# rectangle
|
229
|
+
pdf.stroke_rectangle [241, 146], 145, 20
|
231
230
|
|
232
|
-
|
233
|
-
|
231
|
+
# rectangle
|
232
|
+
pdf.stroke_rectangle [385, 146], 165, 20
|
234
233
|
|
235
|
-
|
236
|
-
|
234
|
+
# staticText
|
235
|
+
pdf.draw_text "PROTOCOLO DE AUTORIZAÇÃO DE USO", :size => 5, :at => [332, 626], :width => 142, :height => 7
|
237
236
|
|
238
|
-
|
239
|
-
|
237
|
+
# textField xml['infProt/nProt'] + ' ' + xml['infProt/dhRecbto']
|
238
|
+
pdf.draw_text xml['infProt/nProt'] + ' ' + xml['infProt/dhRecbto'], :size => 6, :at => [333, 617], :width => 215, :height => 9
|
240
239
|
|
241
|
-
|
242
|
-
|
240
|
+
# staticText
|
241
|
+
pdf.draw_text "Consulta de autenticidade no portal nacional da NF-e www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora", :size => 6, :at => [330, 638], :width => 218, :height => 17
|
243
242
|
|
244
|
-
|
245
|
-
|
243
|
+
# staticText
|
244
|
+
pdf.draw_text "N°.", :size => 7, :at => [446, 728], :width => 9, :height => 9
|
246
245
|
|
247
|
-
|
248
|
-
|
246
|
+
# staticText
|
247
|
+
pdf.draw_text "DESTINATÁRIO / REMETENTE", :size => 5, :at => [-14, 591], :width => 109, :height => 8
|
249
248
|
|
250
|
-
|
251
|
-
|
249
|
+
# staticText
|
250
|
+
pdf.draw_text "CNPJ/CPF", :size => 5, :at => [361, 582], :width => 46, :height => 7
|
252
251
|
|
253
|
-
|
254
|
-
|
252
|
+
# staticText
|
253
|
+
pdf.draw_text "DATA DA EMISSÃO", :size => 5, :at => [474, 582], :width => 49, :height => 7
|
255
254
|
|
256
|
-
|
257
|
-
|
255
|
+
# staticText
|
256
|
+
pdf.draw_text "NOME/RAZÃO SOCIAL", :size => 5, :at => [-11, 582], :width => 107, :height => 7
|
258
257
|
|
259
|
-
|
260
|
-
|
258
|
+
# staticText
|
259
|
+
pdf.draw_text "ENDEREÇO", :size => 5, :at => [-11, 563], :width => 107, :height => 7
|
261
260
|
|
262
|
-
|
263
|
-
|
261
|
+
# staticText
|
262
|
+
pdf.draw_text "BAIRRO / DISTRITO", :size => 5, :at => [293, 563], :width => 69, :height => 7
|
264
263
|
|
265
|
-
|
266
|
-
|
264
|
+
# staticText
|
265
|
+
pdf.draw_text "CEP", :size => 5, :at => [415, 563], :width => 30, :height => 7
|
267
266
|
|
268
|
-
|
269
|
-
|
267
|
+
# staticText
|
268
|
+
pdf.draw_text "FONE/FAX", :size => 5, :at => [217, 546], :width => 49, :height => 7
|
270
269
|
|
271
|
-
|
272
|
-
|
270
|
+
# staticText
|
271
|
+
pdf.draw_text "UF", :size => 5, :at => [326, 546], :width => 17, :height => 7
|
273
272
|
|
274
|
-
|
275
|
-
|
273
|
+
# staticText
|
274
|
+
pdf.draw_text "FATURA / DUPLICATAS", :size => 5, :at => [-14, 530], :width => 109, :height => 7
|
276
275
|
|
277
|
-
|
278
|
-
|
276
|
+
# staticText
|
277
|
+
pdf.draw_text "CÁLCULO DO IMPOSTO", :size => 5, :at => [-14, 479], :width => 109, :height => 7
|
279
278
|
|
280
|
-
|
281
|
-
|
279
|
+
# staticText
|
280
|
+
pdf.draw_text "BASE DE CÁLCULO DO ICMS", :size => 5, :at => [-11, 470], :width => 73, :height => 7
|
282
281
|
|
283
|
-
|
284
|
-
|
282
|
+
# staticText
|
283
|
+
pdf.draw_text "VALOR DO ICMS", :size => 5, :at => [122, 470], :width => 78, :height => 7
|
285
284
|
|
286
|
-
|
287
|
-
|
285
|
+
# staticText
|
286
|
+
pdf.draw_text "BASE DE CÁLCULO DO ICMS ST", :size => 5, :at => [236, 470], :width => 80, :height => 7
|
288
287
|
|
289
|
-
|
290
|
-
|
288
|
+
# staticText
|
289
|
+
pdf.draw_text "VALOR DO ICMS ST", :size => 5, :at => [350, 470], :width => 59, :height => 7
|
291
290
|
|
292
|
-
|
293
|
-
|
291
|
+
# staticText
|
292
|
+
pdf.draw_text "VALOR TOTAL DOS PRODUTOS", :size => 5, :at => [446, 470], :width => 79, :height => 7
|
294
293
|
|
295
|
-
|
296
|
-
|
294
|
+
# staticText
|
295
|
+
pdf.draw_text "TRANSPORTADOR / VOLUMES TRANSPORTADOS DADOS DO PRODUTO / SERVIÇODADOS DO PRODUTO / SERVIÇODADOS DO PRODUTO / SERVIÇO", :size => 5, :at => [-14, 435], :width => 134, :height => 8
|
297
296
|
|
298
|
-
|
299
|
-
|
297
|
+
# staticText
|
298
|
+
pdf.draw_text "RAZÃO SOCIAL", :size => 5, :at => [-11, 426], :width => 64, :height => 7
|
300
299
|
|
301
|
-
|
302
|
-
|
300
|
+
# staticText
|
301
|
+
pdf.draw_text "FRETE POR CONTA", :size => 5, :at => [167, 426], :width => 49, :height => 7
|
303
302
|
|
304
|
-
|
305
|
-
|
303
|
+
# staticText
|
304
|
+
pdf.draw_text "CÓDIGO ANTT", :size => 5, :at => [227, 426], :width => 49, :height => 7
|
306
305
|
|
307
|
-
|
308
|
-
|
306
|
+
# staticText
|
307
|
+
pdf.draw_text "0-EMITENTE 1-DESTINATÁRIO", :size => 4, :at => [167, 416], :width => 44, :height => 12
|
309
308
|
|
310
|
-
|
311
|
-
|
309
|
+
# textField dest/xNome
|
310
|
+
pdf.draw_text xml['dest/xNome'], :size => 7, :at => [-11, 572], :width => 366, :height => 9
|
312
311
|
|
313
|
-
|
314
|
-
|
312
|
+
# textField enderDest/xLgr enderDest/nro
|
313
|
+
pdf.draw_text xml['enderDest/xLgr'] + " " + xml['enderDest/nro'], :size => 7, :at => [-11, 555], :width => 298, :height => 9
|
315
314
|
|
316
|
-
|
317
|
-
|
315
|
+
# textField dest/CNPJ
|
316
|
+
pdf.draw_text xml['dest/CNPJ'], :size => 7, :at => [361, 572], :width => 107, :height => 9
|
318
317
|
|
319
|
-
|
320
|
-
|
318
|
+
# textField ide/dEmi
|
319
|
+
pdf.draw_text xml['ide/dEmi'], :size => 7, :at => [474, 572], :width => 74, :height => 9
|
321
320
|
|
322
|
-
|
323
|
-
|
321
|
+
# textField enderDest/xBairro
|
322
|
+
pdf.draw_text xml['enderDest/xBairro'], :size => 7, :at => [293, 555], :width => 119, :height => 9
|
324
323
|
|
325
|
-
|
326
|
-
|
324
|
+
# textField enderDest/CEP
|
325
|
+
pdf.draw_text xml['enderDest/CEP'], :size => 7, :at => [415, 555], :width => 55, :height => 9
|
327
326
|
|
328
|
-
|
329
|
-
|
327
|
+
# textField enderDest/UF
|
328
|
+
pdf.draw_text xml['enderDest/UF'], :size => 7, :at => [326, 537], :width => 26, :height => 9
|
330
329
|
|
331
|
-
|
332
|
-
|
330
|
+
# textField enderDest/fone
|
331
|
+
pdf.draw_text xml['enderDest/fone'], :size => 7, :at => [217, 537], :width => 104, :height => 9
|
333
332
|
|
334
|
-
|
335
|
-
|
333
|
+
# textField total/vBC
|
334
|
+
pdf.draw_text xml['total/vBC'], :size => 7, :at => [-11, 461], :width => 127, :height => 9
|
336
335
|
|
337
|
-
|
338
|
-
|
336
|
+
# textField total/vICMS
|
337
|
+
pdf.draw_text xml['total/vICMS'], :size => 7, :at => [122, 461], :width => 108, :height => 9
|
339
338
|
|
340
|
-
|
341
|
-
|
339
|
+
# textField total/vBCST
|
340
|
+
pdf.draw_text xml['total/vBCST'], :size => 7, :at => [236, 461], :width => 108, :height => 9
|
342
341
|
|
343
|
-
|
344
|
-
|
342
|
+
# textField total/vST
|
343
|
+
pdf.draw_text xml['total/vST'], :size => 7, :at => [350, 461], :width => 90, :height => 9
|
345
344
|
|
346
|
-
|
347
|
-
|
345
|
+
# textField total/vProd
|
346
|
+
pdf.draw_text xml['total/vProd'], :size => 7, :at => [446, 461], :width => 101, :height => 9
|
348
347
|
|
349
|
-
|
350
|
-
|
348
|
+
# textField transporta/xNome
|
349
|
+
pdf.draw_text xml['transporta/xNome'], :size => 7, :at => [-11, 417], :width => 174, :height => 9
|
351
350
|
|
352
|
-
|
353
|
-
|
351
|
+
# textField transp/modFrete
|
352
|
+
pdf.draw_text xml['transp/modFrete'], :size => 5, :at => [214, 420], :width => 7, :height => 7
|
354
353
|
|
355
|
-
|
356
|
-
|
354
|
+
# textField veicTransp/RNTC
|
355
|
+
pdf.draw_text xml['veicTransp/RNTC'], :size => 5, :at => [227, 417], :width => 69, :height => 9
|
357
356
|
|
358
|
-
|
359
|
-
|
357
|
+
# staticText DATA DA SAÍDA/ENTRADA
|
358
|
+
pdf.draw_text "DATA DA SAÍDA/ENTRADA", :size => 5, :at => [474, 563], :width => 69, :height => 7
|
360
359
|
|
361
|
-
|
362
|
-
|
360
|
+
# staticText HORA DE SAÍDA
|
361
|
+
pdf.draw_text "HORA DE SAÍDA", :size => 5, :at => [474, 546], :width => 53, :height => 7
|
363
362
|
|
364
|
-
|
365
|
-
|
363
|
+
# staticText INSCRIÇÃO ESTADUAL
|
364
|
+
pdf.draw_text "INSCRIÇÃO ESTADUAL", :size => 5, :at => [357, 546], :width => 79, :height => 7
|
366
365
|
|
367
|
-
|
368
|
-
|
366
|
+
# textField $F{NR_IE_DESTINO}
|
367
|
+
pdf.draw_text xml['dest/IE'], :size => 7, :at => [357, 537], :width => 111, :height => 9
|
369
368
|
|
370
|
-
|
371
|
-
|
369
|
+
# textField $F{DS_MUNICIPIO_DESTINO}
|
370
|
+
pdf.draw_text xml['enderDest/xMun'], :size => 7, :at => [-11, 537], :width => 222, :height => 9
|
372
371
|
|
373
|
-
|
374
|
-
|
372
|
+
# staticText MUNICÍPIO
|
373
|
+
pdf.draw_text "MUNICÍPIO", :size => 5, :at => [-11, 546], :width => 107, :height => 7
|
375
374
|
|
376
|
-
|
377
|
-
|
375
|
+
# staticText Número
|
376
|
+
pdf.draw_text "Número", :size => 5, :at => [-11, 522], :width => 57, :height => 7
|
378
377
|
|
379
|
-
|
380
|
-
|
378
|
+
# staticText Vencimento
|
379
|
+
pdf.draw_text "Vencimento", :size => 5, :at => [53, 522], :width => 56, :height => 7
|
381
380
|
|
382
|
-
|
383
|
-
|
381
|
+
# staticText Valor
|
382
|
+
pdf.draw_text "Valor", :size => 5, :at => [116, 522], :width => 55, :height => 7
|
384
383
|
|
385
|
-
|
386
|
-
|
384
|
+
# textField $F{VL_OUTROS}
|
385
|
+
pdf.draw_text xml['total/vOutros'], :size => 7, :at => [258, 443], :width => 86, :height => 9
|
387
386
|
|
388
|
-
|
389
|
-
|
387
|
+
# staticText OUTRAS DESPESAS ACESSÓRIAS
|
388
|
+
pdf.draw_text "OUTRAS DESPESAS ACESSÓRIAS", :size => 5, :at => [258, 452], :width => 84, :height => 7
|
390
389
|
|
391
|
-
|
392
|
-
|
390
|
+
# textField $F{VL_SEGURO}
|
391
|
+
pdf.draw_text xml['total/vSeg'], :size => 7, :at => [79, 443], :width => 83, :height => 9
|
393
392
|
|
394
|
-
|
395
|
-
|
393
|
+
# staticText VALOR DO SEGURO
|
394
|
+
pdf.draw_text "VALOR DO SEGURO", :size => 5, :at => [79, 452], :width => 59, :height => 7
|
396
395
|
|
397
|
-
|
398
|
-
|
396
|
+
# staticText DESCONTO
|
397
|
+
pdf.draw_text "DESCONTO", :size => 5, :at => [168, 452], :width => 35, :height => 7
|
399
398
|
|
400
|
-
|
401
|
-
|
399
|
+
# textField $F{VL_DESCONTO}
|
400
|
+
pdf.draw_text xml['total/vDesc'], :size => 7, :at => [168, 443], :width => 85, :height => 9
|
402
401
|
|
403
|
-
|
404
|
-
|
402
|
+
# staticText VALOR DO FRETE
|
403
|
+
pdf.draw_text "VALOR DO FRETE", :size => 5, :at => [-11, 452], :width => 50, :height => 7
|
405
404
|
|
406
|
-
|
407
|
-
|
405
|
+
# textField $F{VL_FRETE}
|
406
|
+
pdf.draw_text xml['total/vlFrete'], :size => 7, :at => [-11, 443], :width => 84, :height => 9
|
408
407
|
|
409
|
-
|
410
|
-
|
408
|
+
# textField $F{VL_NF}
|
409
|
+
pdf.draw_text xml['total/vNF'], :size => 7, :at => [447, 443], :width => 99, :height => 9
|
411
410
|
|
412
|
-
|
413
|
-
|
411
|
+
# staticText VALOR TOTAL DA NOTA
|
412
|
+
pdf.draw_text "VALOR TOTAL DA NOTA", :size => 5, :at => [447, 452], :width => 61, :height => 7
|
414
413
|
|
415
|
-
|
416
|
-
|
414
|
+
# staticText PLACA DO VEÍCULO
|
415
|
+
pdf.draw_text "PLACA DO VEÍCULO", :size => 5, :at => [301, 426], :width => 69, :height => 7
|
417
416
|
|
418
|
-
|
419
|
-
|
417
|
+
# staticText CNPJ / CPF
|
418
|
+
pdf.draw_text "CNPJ / CPF", :size => 5, :at => [455, 426], :width => 69, :height => 7
|
420
419
|
|
421
|
-
|
422
|
-
|
420
|
+
# textField transporta/CNPJ
|
421
|
+
pdf.draw_text xml['transporta/CNPJ'], :size => 7, :at => [455, 417], :width => 92, :height => 9
|
423
422
|
|
424
|
-
|
425
|
-
|
423
|
+
# textField transporta/xMun
|
424
|
+
pdf.draw_text xml['transporta/xMun'], :size => 7, :at => [249, 399], :width => 177, :height => 10
|
426
425
|
|
427
|
-
|
428
|
-
|
426
|
+
# staticText
|
427
|
+
pdf.draw_text "MUNICÍPIO", :size => 5, :at => [249, 408], :width => 64, :height => 7
|
429
428
|
|
430
|
-
|
431
|
-
|
429
|
+
# textField transporta/xEnder
|
430
|
+
pdf.draw_text xml['transporta/xEnder'], :size => 7, :at => [-11, 399], :width => 255, :height => 9
|
432
431
|
|
433
|
-
|
434
|
-
|
432
|
+
# staticText
|
433
|
+
pdf.draw_text "ENDEREÇO", :size => 5, :at => [-11, 408], :width => 64, :height => 7
|
435
434
|
|
436
|
-
|
437
|
-
|
435
|
+
# staticText
|
436
|
+
pdf.draw_text "QUANTIDADE", :size => 5, :at => [-11, 390], :width => 39, :height => 7
|
438
437
|
|
439
|
-
|
440
|
-
|
438
|
+
# textField vol/qVol
|
439
|
+
pdf.draw_text xml['vol/qVol'], :size => 7, :at => [-11, 381], :width => 60, :height => 9
|
441
440
|
|
442
|
-
|
443
|
-
|
441
|
+
# textField vol/esp
|
442
|
+
pdf.draw_text xml['vol/esp'], :size => 7, :at => [56, 381], :width => 111, :height => 9
|
444
443
|
|
445
|
-
|
446
|
-
|
444
|
+
# staticText
|
445
|
+
pdf.draw_text "ESPÉCIE", :size => 5, :at => [56, 390], :width => 29, :height => 7
|
447
446
|
|
448
|
-
|
449
|
-
|
447
|
+
# staticText
|
448
|
+
pdf.draw_text "MARCA", :size => 5, :at => [173, 390], :width => 62, :height => 7
|
450
449
|
|
451
|
-
|
452
|
-
|
450
|
+
# textField vol/marca
|
451
|
+
pdf.draw_text xml['vol/marca'], :size => 7, :at => [173, 381], :width => 97, :height => 9
|
453
452
|
|
454
|
-
|
455
|
-
|
453
|
+
# staticText
|
454
|
+
pdf.draw_text "NUMERAÇÃO", :size => 5, :at => [280, 390], :width => 62, :height => 7
|
456
455
|
|
457
|
-
|
458
|
-
|
456
|
+
# textField
|
457
|
+
pdf.draw_text "", :size => 7, :at => [280, 381], :width => 103, :height => 9
|
459
458
|
|
460
|
-
|
461
|
-
|
459
|
+
# staticText UF
|
460
|
+
pdf.draw_text "UF", :size => 5, :at => [432, 408], :width => 14, :height => 7
|
462
461
|
|
463
|
-
|
464
|
-
|
462
|
+
# textField tranporta/UF
|
463
|
+
pdf.draw_text xml['tranporta/UF'], :size => 7, :at => [432, 399], :width => 19, :height => 9
|
465
464
|
|
466
|
-
|
467
|
-
|
465
|
+
# textField transporta/IE
|
466
|
+
pdf.draw_text xml['transporta/IE'], :size => 7, :at => [456, 399], :width => 91, :height => 9
|
468
467
|
|
469
|
-
|
470
|
-
|
468
|
+
# staticText
|
469
|
+
pdf.draw_text "INSCRIÇÃO ESTADUAL", :size => 5, :at => [456, 408], :width => 69, :height => 7
|
471
470
|
|
472
|
-
|
473
|
-
|
471
|
+
# staticText
|
472
|
+
pdf.draw_text "PESO BRUTO", :size => 5, :at => [389, 390], :width => 76, :height => 7
|
474
473
|
|
475
|
-
|
476
|
-
|
474
|
+
# textField vol/pesoB
|
475
|
+
pdf.draw_text xml['vol/pesoB'], :size => 7, :at => [389, 381], :width => 76, :height => 9
|
477
476
|
|
478
|
-
|
479
|
-
|
477
|
+
# textField 'vol/pesoL'
|
478
|
+
pdf.draw_text xml['vol/pesoL'], :size => 7, :at => [470, 381], :width => 77, :height => 9
|
480
479
|
|
481
|
-
|
482
|
-
|
480
|
+
# staticText
|
481
|
+
pdf.draw_text "PESO LÍQUIDO", :size => 5, :at => [470, 390], :width => 76, :height => 7
|
483
482
|
|
484
|
-
|
485
|
-
|
483
|
+
# textField transp/pĺaca
|
484
|
+
pdf.draw_text xml['transp/pĺaca'], :size => 7, :at => [301, 417], :width => 125, :height => 9
|
486
485
|
|
487
|
-
|
488
|
-
|
486
|
+
# staticText UF
|
487
|
+
pdf.draw_text "UF", :size => 5, :at => [432, 426], :width => 8, :height => 7
|
489
488
|
|
490
|
-
|
491
|
-
|
489
|
+
# textField transp/UF
|
490
|
+
pdf.draw_text xml['transp/UF'], :size => 7, :at => [432, 417], :width => 18, :height => 9
|
492
491
|
|
493
|
-
|
494
|
-
|
492
|
+
# staticText
|
493
|
+
pdf.draw_text "VALOR DO IPI", :size => 5, :at => [350, 452], :width => 43, :height => 7
|
495
494
|
|
496
|
-
|
497
|
-
|
495
|
+
# textField total/vIPI
|
496
|
+
pdf.draw_text xml['total/vIPI'], :size => 7, :at => [350, 443], :width => 90, :height => 9
|
498
497
|
|
499
|
-
|
500
|
-
|
498
|
+
# staticText
|
499
|
+
pdf.draw_text "DANFE", :size => 10, :at => [267, 689], :width => 58, :height => 12
|
501
500
|
|
502
|
-
|
503
|
-
|
501
|
+
# staticText
|
502
|
+
pdf.draw_text "DOCUMENTO AUXILIAR DA NOTA FISCAL ELETRÔNICA", :size => 5, :at => [266, 675], :width => 60, :height => 17
|
504
503
|
|
505
|
-
|
506
|
-
|
504
|
+
# staticText
|
505
|
+
pdf.draw_text "0 - ENTRADA 1 - SAÍDA", :size => 5, :at => [272, 659], :width => 34, :height => 14
|
507
506
|
|
508
|
-
|
509
|
-
|
507
|
+
# staticText
|
508
|
+
pdf.draw_text "NATUREZA DA OPERAÇÃO", :size => 5, :at => [-11, 626], :width => 107, :height => 7
|
510
509
|
|
511
|
-
|
512
|
-
|
510
|
+
# staticText
|
511
|
+
pdf.draw_text "INSCRIÇÃO ESTADUAL", :size => 5, :at => [-11, 608], :width => 69, :height => 7
|
513
512
|
|
514
|
-
|
515
|
-
|
513
|
+
# staticText
|
514
|
+
pdf.draw_text "INSC.ESTADUAL DO SUBST. TRIBUTÁRIO", :size => 5, :at => [178, 608], :width => 107, :height => 7
|
516
515
|
|
517
|
-
|
518
|
-
|
516
|
+
# staticText
|
517
|
+
pdf.draw_text "CNPJ", :size => 5, :at => [367, 608], :width => 16, :height => 7
|
519
518
|
|
520
|
-
|
521
|
-
|
519
|
+
# textField ide/natOp
|
520
|
+
pdf.draw_text xml['ide/natOp'], :size => 7, :at => [-11, 617], :width => 336, :height => 9
|
522
521
|
|
523
|
-
|
524
|
-
|
522
|
+
# textField emit/IE
|
523
|
+
pdf.draw_text xml['emit/IE'], :size => 7, :at => [-11, 599], :width => 183, :height => 9
|
525
524
|
|
526
|
-
|
527
|
-
|
525
|
+
# textField emit/IE_ST
|
526
|
+
pdf.draw_text xml['emit/IE_ST'], :size => 7, :at => [178, 599], :width => 183, :height => 9
|
528
527
|
|
529
|
-
|
530
|
-
|
528
|
+
# textField emit/CNPJ
|
529
|
+
pdf.draw_text xml['emit/CNPJ'], :size => 7, :at => [367, 599], :width => 181, :height => 9
|
531
530
|
|
532
|
-
|
533
|
-
|
531
|
+
# textField ide/dSaiEnt
|
532
|
+
pdf.draw_text xml['ide/dSaiEnt'], :size => 5, :at => [314, 664], :width => 5, :height => 6
|
534
533
|
|
535
|
-
|
536
|
-
|
534
|
+
# textField ide/serie
|
535
|
+
pdf.draw_text xml['ide/serie'], :size => 6, :at => [287, 643], :width => 38, :height => 7
|
537
536
|
|
538
|
-
|
539
|
-
|
537
|
+
# staticText
|
538
|
+
pdf.draw_text "SÉRIE", :size => 6, :at => [268, 643], :width => 19, :height => 7
|
540
539
|
|
541
|
-
|
542
|
-
|
540
|
+
# textField ide/nNF
|
541
|
+
pdf.draw_text xml['ide/nNF'], :size => 7, :at => [277, 650], :width => 48, :height => 9
|
543
542
|
|
544
|
-
|
545
|
-
|
543
|
+
# staticText
|
544
|
+
pdf.draw_text "DATA DE RECEBIMENTO", :size => 5, :at => [-11, 724], :width => 65, :height => 7
|
546
545
|
|
547
|
-
|
548
|
-
|
546
|
+
# staticText
|
547
|
+
pdf.draw_text "IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR", :size => 5, :at => [63, 724], :width => 259, :height => 7
|
549
548
|
|
550
|
-
|
551
|
-
|
549
|
+
# staticText
|
550
|
+
pdf.draw_text "NF-e", :size => 9, :at => [446, 738], :width => 102, :height => 12
|
552
551
|
|
553
|
-
|
554
|
-
|
552
|
+
# textField ide/serie
|
553
|
+
pdf.draw_text xml['ide/serie'], :size => 7, :at => [472, 719], :width => 76, :height => 9
|
555
554
|
|
556
|
-
|
557
|
-
|
555
|
+
# textField ide/nNF
|
556
|
+
pdf.draw_text xml['ide/nNF'], :size => 7, :at => [455, 728], :width => 93, :height => 9
|
558
557
|
|
559
|
-
|
560
|
-
|
558
|
+
# textField
|
559
|
+
pdf.draw_text "RECEBEMOS DE " + xml['emit/xNome'] + " OS PRODUTOS CONSTANTES DA NOTA FISCAL INDICADA A BAIXO", :size => 5, :at => [-11, 744], :width => 450, :height => 8
|
561
560
|
|
562
|
-
|
563
|
-
|
561
|
+
# staticText
|
562
|
+
pdf.draw_text "SÉRIE", :size => 7, :at => [446, 719], :width => 26, :height => 9
|
564
563
|
|
565
|
-
|
566
|
-
|
564
|
+
# staticText
|
565
|
+
pdf.draw_text "CHAVE DE ACESSO", :size => 5, :at => [331, 668], :width => 67, :height => 7
|
567
566
|
|
568
|
-
|
569
|
-
|
567
|
+
# staticText
|
568
|
+
pdf.draw_text "FOLHA", :size => 6, :at => [268, 636], :width => 19, :height => 7
|
570
569
|
|
571
|
-
|
572
|
-
|
570
|
+
# textField
|
571
|
+
pdf.draw_text " 1 / 1", :size => 6, :at => [287, 636], :width => 9, :height => 7
|
573
572
|
|
574
|
-
|
575
|
-
|
573
|
+
# textField chNFe
|
574
|
+
pdf.draw_text xml['chNFe'], :size => 6, :at => [331, 659], :width => 217, :height => 9
|
576
575
|
|
577
|
-
|
578
|
-
|
576
|
+
# staticText
|
577
|
+
pdf.draw_text "DADOS DO PRODUTO / SERVIÇO", :size => 5, :at => [-14, 372], :width => 134, :height => 8
|
579
578
|
|
580
|
-
|
581
|
-
|
579
|
+
# staticText
|
580
|
+
pdf.draw_text "N°", :size => 7, :at => [268, 650], :width => 10, :height => 9
|
582
581
|
|
583
|
-
|
584
|
-
|
582
|
+
# textField emit/xNome
|
583
|
+
pdf.draw_text xml['emit/xNome'], :size => 7, :at => [62, 680], :width => 198, :height => 21
|
585
584
|
|
586
|
-
|
587
|
-
|
585
|
+
# textField enderEmit/xLgr enderEmit/nro
|
586
|
+
pdf.draw_text xml['enderEmit/xLgr'] + ", " + xml['enderEmit/nro'], :size => 7, :at => [62, 669], :width => 198, :height => 10
|
588
587
|
|
589
|
-
|
590
|
-
|
588
|
+
# textField enderEmit/xBairro
|
589
|
+
pdf.draw_text xml['enderEmit/xBairro'] + " - " + xml['enderEmit/CEP'], :size => 7, :at => [62, 659], :width => 198, :height => 10
|
591
590
|
|
592
|
-
|
593
|
-
|
591
|
+
# textField enderEmit/xMun enderEmit/UF
|
592
|
+
pdf.draw_text xml['enderEmit/xMun'] + "/" + xml['enderEmit/UF'], :size => 6, :at => [62, 649], :width => 198, :height => 10
|
594
593
|
|
595
|
-
|
596
|
-
|
594
|
+
# textField enderEmit/fone enderEmit/email
|
595
|
+
pdf.draw_text xml['enderEmit/fone'] + " " + xml['enderEmit/email'], :size => 6, :at => [62, 639], :width => 198, :height => 10
|
597
596
|
|
598
|
-
|
599
|
-
|
597
|
+
# textField ide/dSaiEnt
|
598
|
+
pdf.draw_text xml['ide/dSaiEnt'], :size => 7, :at => [474, 555], :width => 74, :height => 9
|
600
599
|
|
601
|
-
|
602
|
-
|
600
|
+
# textField ide/dSaiEnt
|
601
|
+
pdf.draw_text xml['ide/dSaiEnt'], :size => 7, :at => [474, 537], :width => 74, :height => 9
|
603
602
|
|
604
|
-
|
605
|
-
|
603
|
+
# staticText
|
604
|
+
pdf.draw_text "Número", :size => 5, :at => [178, 522], :width => 57, :height => 7
|
606
605
|
|
607
|
-
|
608
|
-
|
606
|
+
# staticText
|
607
|
+
pdf.draw_text "Vencimento", :size => 5, :at => [242, 522], :width => 56, :height => 7
|
609
608
|
|
610
|
-
|
611
|
-
|
609
|
+
# staticText
|
610
|
+
pdf.draw_text "Valor", :size => 5, :at => [305, 522], :width => 55, :height => 7
|
612
611
|
|
613
|
-
|
614
|
-
|
612
|
+
# staticText
|
613
|
+
pdf.draw_text "Número", :size => 5, :at => [367, 522], :width => 57, :height => 7
|
615
614
|
|
616
|
-
|
617
|
-
|
615
|
+
# staticText
|
616
|
+
pdf.draw_text "Vencimento", :size => 5, :at => [431, 522], :width => 56, :height => 7
|
618
617
|
|
619
|
-
|
620
|
-
|
618
|
+
# staticText
|
619
|
+
pdf.draw_text "Valor", :size => 5, :at => [494, 522], :width => 50, :height => 7
|
621
620
|
|
622
|
-
|
623
|
-
|
621
|
+
# textField infAdic/infCpl
|
622
|
+
pdf.draw_text xml['infAdic/infCpl'], :size => 6, :at => [-10, -50], :width => 334, :height => 161
|
624
623
|
|
625
|
-
|
626
|
-
|
624
|
+
# staticText
|
625
|
+
pdf.draw_text "DADOS ADICIONAIS", :size => 5, :at => [-14, 121], :width => 134, :height => 7
|
627
626
|
|
628
|
-
|
629
|
-
|
627
|
+
# staticText
|
628
|
+
pdf.draw_text "CÁLCULO DO ISSQN", :size => 5, :at => [-14, 150], :width => 134, :height => 8
|
630
629
|
|
631
|
-
|
632
|
-
|
630
|
+
# staticText
|
631
|
+
pdf.draw_text "INSCRIÇÃO MUNICIPAL", :size => 5, :at => [-11, 141], :width => 83, :height => 8
|
633
632
|
|
634
|
-
|
635
|
-
|
633
|
+
# staticText
|
634
|
+
pdf.draw_text "VALOR TOTAL DOS SERVIÇOS", :size => 5, :at => [100, 141], :width => 103, :height => 8
|
636
635
|
|
637
|
-
|
638
|
-
|
636
|
+
# textField total/vServ
|
637
|
+
pdf.draw_text xml['total/vServ'], :size => 7, :at => [100, 130], :width => 138, :height => 10
|
639
638
|
|
640
|
-
|
641
|
-
|
639
|
+
# textField emit/IM
|
640
|
+
pdf.draw_text xml['emit/IM'], :size => 7, :at => [-11, 130], :width => 105, :height => 10
|
642
641
|
|
643
|
-
|
644
|
-
|
642
|
+
# staticText
|
643
|
+
pdf.draw_text "BASE DE CÁLCULO DO ISSQN", :size => 5, :at => [244, 141], :width => 103, :height => 8
|
645
644
|
|
646
|
-
|
647
|
-
|
645
|
+
# textField total/vBCISS
|
646
|
+
pdf.draw_text xml['total/vBCISS'], :size => 7, :at => [244, 130], :width => 138, :height => 10
|
648
647
|
|
649
|
-
|
650
|
-
|
648
|
+
# staticText
|
649
|
+
pdf.draw_text "VALOR DO ISSQN", :size => 5, :at => [388, 141], :width => 103, :height => 8
|
651
650
|
|
652
|
-
|
653
|
-
|
651
|
+
# textField total/ISSTot
|
652
|
+
pdf.draw_text xml['total/ISSTot'], :size => 7, :at => [388, 130], :width => 159, :height => 10
|
654
653
|
|
655
|
-
|
656
|
-
|
654
|
+
# textField
|
655
|
+
pdf.draw_text "", :size => 6, :at => [331, -50], :width => 216, :height => 163
|
657
656
|
|
658
|
-
|
659
|
-
|
657
|
+
# staticText
|
658
|
+
pdf.draw_text "RESERVADO AO FISCO", :size => 5, :at => [331, 113], :width => 96, :height => 7
|
660
659
|
|
661
|
-
|
662
|
-
|
660
|
+
# staticText
|
661
|
+
pdf.draw_text "INFORMAÇÕES COMPLEMENTARES", :size => 5, :at => [-11, 112], :width => 93, :height => 7
|
663
662
|
|
664
|
-
|
665
|
-
|
663
|
+
return pdf
|
664
|
+
|
665
|
+
end
|
666
|
+
|
667
|
+
def self.render(xml_string)
|
668
|
+
xml = XML.new(xml_string)
|
669
|
+
pdf = generatePDFFromXML(xml)
|
670
|
+
return pdf.render
|
671
|
+
end
|
672
|
+
|
673
|
+
def self.generate(pdf_filename, xml_filename)
|
674
|
+
xml = XML.new(File.new(xml_filename))
|
675
|
+
pdf = generatePDFFromXML(xml)
|
676
|
+
pdf.render_file pdf_filename
|
666
677
|
end
|
667
678
|
|
668
679
|
end
|
data/ruby_danfe.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_danfe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Eduardo Rebou\xC3\xA7as"
|