-
Notifications
You must be signed in to change notification settings - Fork 2
/
BOLETOPDF.prw
532 lines (420 loc) · 17.3 KB
/
BOLETOPDF.prw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
#Include "Protheus.Ch"
#Include "RwMake.Ch"
#Include "Totvs.Ch"
#Include "RPTDEF.CH"
#Include "FWPrintSetup.ch"
/* #########################################################################################
// -----------------------------------------+----------------------------------------------+
// Modulo :FINANCEIRO |
// Fonte :BOLETOPDF() |
// -----------+-------------------+--------------------------------------------------------+
// Data | Autor | Descricao |
// -----------+-------------------+--------------------------------------------------------+
// 10/07/2020 | Michael M. Castro | Layout de Boleto Modelo Grafico em PDF |
// -----------+-------------------+--------------------------------------------------------+
// #########################################################################################*/
User Function BOLETOPDF()
//-------------------------------------------------------------------------+
// Inicializacao do objeto grafico |
//-------------------------------------------------------------------------+
Local n_Lin := 0
Local n_Col := 0
Local n_hLin := 0
Local n_LinSav := 0
Local n_SavLin2 := 0
Local n_VLin := 0
Local n_VCol := 0
Local PixelX := nil
Local PixelY := nil
Local oFont10N
Local oFont07N
Local oFont07
Local oFont08
Local oFont08N
Local oFont09N
Local oFont09
Local oFont10
Local oFont11
Local oFont12
Local oFont11N
Local oFont18N
Local OFONT12N
Local VBOX := 080
Local HMARGEM := 080
Local VMARGEM := 030
Local cBanco := "033"
Local cLinDig := "123456789123456789123458912345678912315469789132154987888"
Local cAgencia := "3025"
Local cConven := "22222222"
Local cConta := "111111-2"
Local cNumBco := "0123456789"
Local cNumTit := "002 123456789 001"
Local nValBol := 50200.55
Local nDescre := 1.5
Local cNomeCli := "ADVPL"
Local cEndCli := "RUA TESTE DOS SANTOS, 1050"
Local cCep := "12345-236"
Local cMunic := "SÃO PAULO"
Local cUF := "SP"
Local cNomEmp := "DESENVOLVENDO LAYOUT BOLETO PDF"
Local cMsgBol := "Mensagem para Boleto"
Local cEspecDoc:= "DM"
Local cAceite := "S"
Local dDtaEmis := Date()
Local dDtaVenc := Date()+15
Local cUsoBco := "BCO"
Local cCodCart := "101"
Local cInstru1 := "Instrução 1"
Local cInstru2 := "Instrução 2"
Local cInstru3 := "Instrução 3"
Local cInstru4 := "Instrução 4"
Local cCodBar := "12348912315469789135678923456789124589123456"
Local cArquivoPDF := "santander.rel"
Local cLogoBco := "C:\CNAB\santander.png"
Local oBoleto
// ----------------------------------------------------------------+
// Define saida de impressão |
// ----------------------------------------------------------------+
oBoleto := FWMSPrinter():New(cArquivoPDF, IMP_PDF, .F.,, .T., , , , , , .F., )
oBoleto:SetResolution(78)
oBoleto:SetPortrait()
oBoleto:SetPaperSize(DMPAPER_A4)
oBoleto:SetMargin(60,60,60,60)
PixelX := oBoleto:nLogPixelX()
PixelY := oBoleto:nLogPixelY()
//--------------------------------------------------------------------------+
// processa o desenho |
//--------------------------------------------------------------------------+
oFont10N := TFont():New("Times New Roman", ,-08,.T.,.F.)// 1
oFont07N := TFont():New("Times New Roman", ,-06,.T.,.F.)// 2
oFont07 := TFont():New("Times New Roman", ,-06,.F.,.F.)// 3
oFont08 := TFont():New("Times New Roman", ,-07,.F.,.F.)// 4
oFont08N := TFont():New("Times New Roman", ,-06,.T.,.F.)// 5
oFont09N := TFont():New("Times New Roman", ,-08,.T.,.F.)// 6
oFont09 := TFont():New("Times New Roman", ,-08,.F.,.F.)// 7
oFont10 := TFont():New("Times New Roman", ,-09,.F.,.F.)// 8
oFont11 := TFont():New("Times New Roman", ,-10,.F.,.F.)// 9
oFont12 := TFont():New("Times New Roman", ,-11,.F.,.F.)// 10
oFont12N := TFont():New("Times New Roman", ,-11,.T.,.F.)// 10
oFont14N := TFont():New("Times New Roman", ,-12,.T.,.T.)// 10
oFont11N := TFont():New("Times New Roman", ,-10,.T.,.F.)// 11
oFont18N := TFont():New("Times New Roman", ,-17,.T.,.T.)// 12
oFONT12N := TFont():New("Times New Roman", ,-11,.T.,.F.)// 12
//---------------------------------------------------------------------------+
// Inicializacao da pagina do objeto grafico |
///--------------------------------------------------------------------------+
oBoleto:StartPage()
//+----------------------------+
// Linha da Margem
//+----------------------------+
oBoleto:Box( 10, 10, 830, 600, "-4")
nHPage := oBoleto:nHorzRes()
nHPage *= (300/PixelX)
nHPage -= HMARGEM
nVPage := oBoleto:nVertRes()
nVPage *= (300/PixelY)
nVPage -= VBOX
//---------------------------------------------------------------------------+
// Desenha o Recibo do Sacado. |
//---------------------------------------------------------------------------+
oBoleto:Box(HMARGEM,VMARGEM,038,578)
oBoleto:Line(58,VMARGEM, 58, 578, 0, "-4")
oBoleto:Box(HMARGEM,VMARGEM,038,433)
oBoleto:Line(58,VMARGEM, 58, 578, 0, "-4")
oBoleto:Box(HMARGEM,VMARGEM,038,289)
oBoleto:Line(58,VMARGEM, 58, 578, 0, "-4")
oBoleto:Box(HMARGEM,VMARGEM,038,144)
oBoleto:Line(58,VMARGEM, 58, 578, 0, "-4")
//+----------------+
//Logo do Banco |
//+----------------+
oBoleto:SayBitmap( 005, 030, cLogoBco, 90, 40)
// Banco e Linha Digitável
//oBoleto:Say(034,032, cNomeBco+" | "+cBanco+" | ", oFont18N)
oBoleto:Say(030,130, " | "+cBanco+" | ", oFont18N)
oBoleto:Say(034,240, Transform(cLinDig, "@R 99999.99999 99999.999999 99999.999999 9 99999999999999"), oFont14N) // --> LINHA DIGITAVEL CB ( 23790.12301 60000.000038 78000.456703 3 49130000042790 )
oBoleto:Say(034,505, "Recibo do Sacado", oFont12N)
// Títulos da primeira linha de boxes
oBoleto:Say(044,032, "Vencimento", oFont07)
// Mudanca no texto do boleto solicitado pelo SAFRA
IF cBanco $ "033/353/422"
oBoleto:Say(044,146, "Agência/Código do Beneficiario", oFont07)
ELSE
oBoleto:Say(044,146, "Agência/Código do Cedente", oFont07)
ENDIF
oBoleto:Say(044,291, "Número do Documento", oFont07)
oBoleto:Say(044,435, "Nosso Número/Código do Documento", oFont07)
// Títulos da segunda linha de boxes
// Lin Col
oBoleto:Say(064,032, "Valor do Documento", oFont07)
oBoleto:Say(064,146, "(-) Descontos", oFont07)
oBoleto:Say(064,291, "(+) Acréscimos", oFont07)
oBoleto:Say(064,435, "(=) Valor Cobrado", oFont07)
// Dados da primeira linha de boxes
oBoleto:Say(056,070, DTOC(dDtaVenc), oFont12)
IF cBanco $ "033/353/422"
oBoleto:Say(056,150, cAgencia +" / "+ cConven, oFont12)
Else
oBoleto:Say(056,150, cAgencia +" / "+ cConta, oFont12)
EndIf
oBoleto:Say(056,300, cNumTit , oFont12)
oBoleto:Say(056,450, cNumBco, oFont12)
// Dados da segunda linha de boxes
oBoleto:Say(076,080, Transform(nValBol, PesqPict("SE1","E1_SALDO")), oFont12)
If nDescre > 0
oBoleto:Say(076,200, Transform(nDescre, PesqPict("SE1","E1_DECRESC")), oFont12)
EndIf
//---------------------------------------------------------------------------+
// Dados do Sacado (Recibo do Sacado). |
//---------------------------------------------------------------------------+
oBoleto:Say(086,032, "Sacado", oFont07)
//oBoleto:Say(086,435, "------------------- Autenticação Mecânica -------------------", oFont07)
oBoleto:Say(088 , 080, cNomeCli, oFont12)
oBoleto:Say(088 + 10 , 080, cEndCli, oFont12)
oBoleto:Say(088 + (2*10), 080, "CEP: "+cCep+" "+cMunic+" - "+cUF, oFont12 )
//---------------------------------------------------------------------------+
// Dados do Sacador Avalista/cedente. BLOCO 1 |
//---------------------------------------------------------------------------+
oBoleto:Say(128,032, "Sacador/Avalista", oFont07)
// Inicia Linha
n_Lin := 130
oBoleto:Say(n_Lin, 080, cNomEmp, oFont12)
n_Lin += 14
// Linha Pontilhada
n_Lin += 16
oBoleto:Say(n_Lin,VMARGEM, Replicate("-",177), oFont12)
//---------------------------------------------------------------------------+
// Desenha o Boleto (Ficha de Compensação). |
//---------------------------------------------------------------------------+
// Banco e Linha Digitável
n_Lin += 20
//+----------------+
//Logo do Banco |
//+----------------+
oBoleto:SayBitmap(n_Lin-28, 030, cLogoBco, 90, 40)
oBoleto:Say(n_Lin,130, " | "+cBanco+" | ", oFont18N)
//oBoleto:Say(n_Lin,032, cNomeBco+" | "+cBanco+" | ", oFont18N)
oBoleto:Say(n_Lin,315, Transform(cLinDig, "@R 99999.99999 99999.999999 99999.999999 9 99999999999999"), oFont14N)
// Box Geral
n_Lin += 5
oBoleto:Box(n_Lin,VMARGEM,n_Lin+240,578)
n_LinSav := n_Lin
// Coluna Principal
n_Col := 415
oBoleto:Line(n_Lin,n_Col, n_Lin+180, n_Col, 0, "-4")
// Colunas da 3a. Linha da Ficha
n_VLin := n_Lin + 40
n_VCol := 280
oBoleto:Box(n_VLin,n_VCol,n_VLin+20,n_VCol+50)
n_VCol := 230
oBoleto:Box(n_VLin,n_VCol,n_VLin+20,n_VCol+50)
n_VCol := 100
oBoleto:Box(n_VLin,n_VCol,n_VLin+20,230)
// Colunas da 4a Linha da Ficha
n_VLin += 20
n_VCol := 330
oBoleto:Box(n_VLin,n_VCol,n_VLin+20,n_VCol+85)
n_VCol := 230
oBoleto:Box(n_VLin,n_VCol,n_VLin+20,330)
n_VCol := 165
oBoleto:Box(n_VLin,n_VCol,n_VLin+20,230)
n_VCol := VMARGEM
oBoleto:Box(n_VLin,n_VCol,n_VLin+20,100)
// Define a altura da linha
n_hLin := 20
// Linhas
oBoleto:Line(n_Lin+n_hLin, VMARGEM, n_Lin+n_hLin, 578, 0, "-4")
n_Lin += n_hLin
oBoleto:Line(n_Lin+n_hLin, VMARGEM, n_Lin+n_hLin, 578, 0, "-4")
n_Lin += n_hLin
oBoleto:Line(n_Lin+n_hLin, VMARGEM, n_Lin+n_hLin, 578, 0, "-4")
n_Lin += n_hLin
oBoleto:Line(n_Lin+n_hLin, VMARGEM, n_Lin+n_hLin, 578, 0, "-4")
n_Lin += n_hLin
oBoleto:Line(n_Lin+n_hLin, n_Col, n_Lin+n_hLin, 578, 0, "-4")
n_Lin += n_hLin
oBoleto:Line(n_Lin+n_hLin, n_Col, n_Lin+n_hLin, 578, 0, "-4")
n_Lin += n_hLin
oBoleto:Line(n_Lin+n_hLin, n_Col, n_Lin+n_hLin, 578, 0, "-4")
n_Lin += n_hLin
oBoleto:Line(n_Lin+n_hLin, n_Col, n_Lin+n_hLin, 578, 0, "-4")
n_Lin += n_hLin
oBoleto:Line(n_Lin+n_hLin, VMARGEM, n_Lin+n_hLin, 578, 0, "-4")
// Titulo Box Sacado/Sacador Avalista
oBoleto:Say(n_Lin+27,VMARGEM+2, "Sacado", oFont07)
oBoleto:Say(n_Lin+70,VMARGEM+2, "Sacador/Avalista", oFont07)
// Autenticacao
n_Lin += 60 + n_hLin + 7
oBoleto:Say(n_Lin,435, "Autenticação Mecânica/Ficha de Compensação", oFont07)
//---------------------------------------------------------------------------+
// Título dos Quadros da Ficha de Compensacao |
//---------------------------------------------------------------------------+
// 1a. Linha
n_Lin := n_LinSav + 6
n_Col := 032
oBoleto:Say(n_Lin, n_Col, "Local de Pagamento", oFont07)
n_Col := 418
oBoleto:Say(n_Lin, n_Col, "Vencimento", oFont07)
// 2a. Linha
n_Lin += n_hLin
n_Col := 032
oBoleto:Say(n_Lin, n_Col, "Beneficiario", oFont07)
n_Col := 418
oBoleto:Say(n_Lin, n_Col, "Agência/Código do Beneficiario", oFont07)
// 3a. Linha
n_Lin += n_hLin
n_Col := 032
oBoleto:Say(n_Lin, n_Col, "Data do Documento", oFont07)
n_Col := 102
oBoleto:Say(n_Lin, n_Col, "Número do Documento", oFont07)
n_Col := 232
oBoleto:Say(n_Lin, n_Col, "Espécie Doc.", oFont07)
n_Col := 282
oBoleto:Say(n_Lin, n_Col, "Aceite", oFont07)
n_Col := 332
oBoleto:Say(n_Lin, n_Col, "Data do Processamento", oFont07)
n_Col := 417
oBoleto:Say(n_Lin, n_Col, "Nosso Número", oFont07)
// 4a. Linha
n_Lin += n_hLin
n_Col := 032
oBoleto:Say(n_Lin, n_Col, "Uso do Banco", oFont07)
n_Col := 102
oBoleto:Say(n_Lin, n_Col, "Carteira", oFont07)
n_Col := 167
oBoleto:Say(n_Lin, n_Col, "Espécie", oFont07)
n_Col := 232
oBoleto:Say(n_Lin, n_Col, "Quantidade", oFont07)
n_Col := 332
oBoleto:Say(n_Lin, n_Col, "(X) Valor", oFont07)
n_Col := 417
oBoleto:Say(n_Lin, n_Col, "(=) Valor do Documento", oFont07)
oBoleto:Say(n_Lin+21,VMARGEM+2, "Instruções - Texto de Responsabilidade do Cedente", oFont07)
n_SavLin2 := n_Lin
// 5a. Linha (Coluna Direita)
n_Lin += n_hLin
n_Col := 417
oBoleto:Say(n_Lin, n_Col, "(-) Descontos / Abatimentos", oFont07)
// 6a. Linha (Coluna Direita)
n_Lin += n_hLin
n_Col := 417
oBoleto:Say(n_Lin, n_Col, "(-) Outras Deduções", oFont07)
// 7a. Linha (Coluna Direita)
n_Lin += n_hLin
n_Col := 417
oBoleto:Say(n_Lin, n_Col, "(+) Mora Multa", oFont07)
// 8a. Linha (Coluna Direita)
n_Lin += n_hLin
n_Col := 417
oBoleto:Say(n_Lin, n_Col, "(+) Outros Acréscimos", oFont07)
// 9a. Linha (Coluna Direita)
n_Lin += n_hLin
n_Col := 417
oBoleto:Say(n_Lin, n_Col, "(=) Valor Cobrado", oFont07)
//---------------------------------------------------------------------------+
// Texto/Detalhes da Ficha de Compensacao |
//---------------------------------------------------------------------------+
// 1a. Linha
n_Lin := n_LinSav + (n_hLin-2)
n_Col := VMARGEM+10
oBoleto:Say(n_Lin, n_Col, cMsgBol, oFont12)
oBoleto:Say(n_Lin,480, DTOC(dDtaVenc), oFont12)
// 2a. Linha
n_Lin += n_hLin-2
oBoleto:Say(n_Lin, n_Col, cNomEmp, oFont12)
oBoleto:Say(n_Lin,460, cAgencia +" / "+ cConta , oFont12)
// 3a. Linha
n_Lin += n_hLin
oBoleto:Say(n_Lin, n_Col, DTOC(dDtaEmis), oFont12)
n_Col := 120
oBoleto:Say(n_Lin, n_Col, cNumTit, oFont12)
n_Col := 240
oBoleto:Say(n_Lin, n_Col, cEspecDoc, oFont12)
n_Col := 300
oBoleto:Say(n_Lin, n_Col, cAceite, oFont12)
n_Col := 340
oBoleto:Say(n_Lin, n_Col, DTOC(dDtaEmis), oFont12)
n_Col := 480
oBoleto:Say(n_Lin, n_Col, cNumBco, oFont12)
// 4a. Linha
n_Lin += n_hLin
n_Col := VMARGEM+10
oBoleto:Say(n_Lin, n_Col, cUsoBco, oFont12)
n_Col := 120
oBoleto:Say(n_Lin, n_Col, cCodCart, oFont12)
n_Col := 180
oBoleto:Say(n_Lin, n_Col, "R$", oFont12)
n_Col := 480
oBoleto:Say(n_Lin, n_Col, Transform(nValBol, PesqPict("SE1","E1_SALDO")), oFont12)
// 5a. Linha (Coluna à direita)
n_Lin += n_hLin
n_Col := 480
If nDescre > 0
oBoleto:Say(n_Lin, n_Col, Transform(nDescre, PesqPict("SE1","E1_DECRESC")), oFont12)
EndIf
// 6a. Linha (Coluna à direita)
// --> Outros acréscimos - nao sera impressa
n_Lin += n_hLin
//7a. Linha (Coluna à direita)
n_Lin += n_hLin
n_Col := 480
//8a. Linha (Coluna à direita)
n_Lin += n_hLin
n_Col := 480
//9a. Linha (Coluna à direita)
n_Lin += n_hLin
n_Col := 480
//---------------------------------------------------------------------------+
// Texto/Box (Instruções Bancárias). |
//---------------------------------------------------------------------------+
n_hLin := 10
n_Lin := n_SavLin2 + (4* n_hLin ) - 5
n_Col := VMARGEM+10
oBoleto:Say(n_Lin, n_Col, AllTrim(cInstru1), oFont12)
n_Lin += n_hLin
oBoleto:Say(n_Lin, n_Col, AllTrim(cInstru2), oFont12)
n_Lin += n_hLin
oBoleto:Say(n_Lin, n_Col, AllTrim(cInstru3), oFont12)
n_Lin += n_hLin
oBoleto:Say(n_Lin, n_Col, AllTrim(cInstru4), oFont12)
n_Lin += 10
//n_Lin += n_hLin
oBoleto:Say(n_Lin+10, n_Col, "PARA REGULARIZAÇÃO DE PROTESTO POR FAVOR ACESSAR O SITE:", oFont12)
//n_Lin += n_hLin
oBoleto:Say(n_Lin+20, n_Col, "https://protestosp.com.br/, clicar na opção SERVIÇOS ELETRONICOS DE", oFont12)
//n_Lin += n_hLin
oBoleto:Say(n_Lin+30, n_Col, "PROTESTO, EFETUAR O CADASTRO E PAGAR O BOLETO.", oFont12)
//---------------------------------------------------------------------------+
// Dados do Sacado (Ficha de Compensacao). BLOCO 2 ANTES DO CODIGO DE BARRA |
//---------------------------------------------------------------------------+
oBoleto:Say(n_Lin += 50 , 080, cNomeCli , oFont12)
oBoleto:Say(n_Lin += 10 , 080, cEndCli , oFont12)
oBoleto:Say(n_Lin += 10 , 080, "CEP: "+cCep+" "+cMunic+" - "+cUF, oFont12 )
//---------------------------------------------------------------------------+
// Imprime os dados do Sacador Avalista/cedente. |
//---------------------------------------------------------------------------+
n_Lin += 21
oBoleto:Say(n_Lin, 080, cNomEmp, oFont12)
n_Lin += 12
//---------------------------------------------------------------------------+
// Código de Barras |
//---------------------------------------------------------------------------+
oBoleto:FwMsBar("INT25", 37, 2.5, cCodBar, oBoleto, .F., CLR_BLACK,.T.,0.02,0.8,.F.)
//---------------------------------------------------------------------------+
// Finalizar a Página. |
//---------------------------------------------------------------------------+
oBoleto:EndPage()
//---------------------------------------------------------------------------+
// Visualiza o Boleto em PDF |
//---------------------------------------------------------------------------+
oBoleto:Setup()
If oBoleto:nModalResult == PD_OK
oBoleto:Preview()
EndIf
//=================================================================================+
// Finalizar o Boleto PDF. |
// |
//=================================================================================+
FreeObj(oBoleto)
Ms_Flush()
Return