PDF usando HTML facim, facim!
cHtml := '<!DOCTYPE html><html><head>'
cHtml += '<link rel="stylesheet" type="text/css" href="/print.css" media="print" />'
cHtml += '<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>'
cHtml += '<title>Orçamento</title>'
cHtml += '<style>'
cHtml += 'table,th,td{'
cHtml += ' FONT: 12pt "Courier New";'
cHtml += ' border: 1px solid #888;'
cHtml += ' border-collapse:collapse;'
cHtml += ' color:#000000;'
cHtml += ' table-layout: fixed; width: auto'
cHtml += '}'
cHtml += 'p.quebra { page-break-before: always }'
cHtml += 'ft.a { font: 14px Arial; font-weight: bold ; } '
cHtml += 'ft.b { font: 11px sans-serif; }'
cHtml += 'ft.c { font: 12px Arial; }'
cHtml += 'ft.d { font: 13px Arial; }'
cHtml += '.zebra tbody tr:nth-child(2n+2) { background: #ccc; } '
cHtml += '</style>'
cHtml += '</head><body><div align="center">'
cHtml += '<table cellpadding="1" cellspacing="1">'
cHtml += '<col width="150px"/>'
cHtml += '<col width="990px"/>'
cHtml += '<col width="260px"/>'
cHtml += '<tr>'
cHtml += '<td> <img src="./imagens/logoempresa.png" width="125" height="76" alt="Logo Empresa" > </td>'
cHtml += '<td align="center" style="font-family:verdana;font-weight:bold">' + em->empresa
cHtml += '<br> <ft class="b"> ' + AllTrim(em->endereco) + ", Nº " + em->numero + ", " + AllTrim(em->cidade) + "/" + em->uf
cHtml += '<br> Fone: ' + Transform(alltrim(em->telefone),'@R (99) 9999-9999')
cHtml += ' -- <img src="./imagens/whatsapp_.jpg" width="16" height="16" alt="Logo zap" > '
cHtml += Transform(alltrim(em->whatsapp),'@R (99) 99999-9999') + '</td>'
cHtml += '<td> <ft class="a"> Orçamento PDV: ' + StrZero(nPDV,3) + '</ft><br>' + str(day(dDia),2)+"/"+SubStr(CMonth(dDia),1,3)+'/'+str(year(dDia),4)+'<br>'+ampm(Transform(cHora,"@R 99:99:99"))
cHtml += '</td></tr></table>'
cHtml += '<table cellpadding="1" cellspacing="1">'
cHtml += '<col width="1000px"/>'
cHtml += '<col width="700px"/>'
cHtml += '<tr><td colspan=2> Cliente: ' + cCliente + '</td>'
cHtml += '<tr><td colspan=2> Vendedor: ' + pd->vendedor
cHtml += '</td></tr>'
cHtml += '</table>'
cHtml += '<table cellpadding="1" cellspacing="1" class="zebra">'
cHtml += '<col width="100px"/>'
cHtml += '<col width="780px"/>'
cHtml += '<col width="100px"/>'
cHtml += '<col width="100px"/>'
cHtml += '<col width="100px"/>'
cHtml += '<col width="100px"/>'
cHtml += '<col width="100px"/>'
cHtml += '<tr>'
cHtml += '<th> Código </th>'
cHtml += '<th> Descrição </th>'
cHtml += '<th> Qtd.Und. </th>'
cHtml += '<th> A VISTA </th>'
cHtml += '<th> TOTAL </th>'
cHtml += '<th> A PRAZO </th>'
cHtml += '<th> Total </th></tr>'
nTotAvista := 0; nTotAprazo := 0 //; nSemDesc:= 0; nDesconto := 0
Do WHILE pd->(!eof())
if eq->(DbSeek( pd->cod_mercad) )
else
hwg_Msginfo('Não Foi Encontrado no Estoque')
pd->(DbSkip())
loop
endif
cHtml += '<tr>'
cHtml += '<td><ft class="c">' + pd->cod_mercad + '</c></td>'
cHtml += '<td><ft class="d">' + pd->mercadoria + '</d></td>'
if es->(dbseek(eq->unidade))
if es->precisao = 0
cHtml += '<td align=right>' + Transform( pd->quantidade,'99,999,999')+ '</td>'
elseif es->precisao = 1
cHtml += '<td align=right>' + Transform( pd->quantidade,'9999,999.9')+ '</td>'
elseif es->precisao = 2
cHtml += '<td align=right>' + Transform( pd->quantidade,'999,999.99')+ '</td>'
elseif es->precisao = 3
cHtml += '<td align=right>' + Transform( pd->quantidade,'99,999.999')+ '</td>'
endif
else
cHtml += '<td align=right>'+transform( pd->quantidade,'99,999,999')+ '</td>'
endif
cHtml += '<td align=right>' + transform( pd->preco_unit,'@e 9999,999.99') + '</td>'
cHtml += '<td align=right>' + transform(Round( pd->quantidade* pd->preco_unit,2),'@e 9999,999.99')+'</td>'
cHtml += '<td align=right>' + transform(eq->prazo ,'@e 9999,999.99') + '</td>'
cHtml += '<td align=right>' + transform(Round(eq->prazo*pd->quantidade,2) ,'@e 9999,999.99') + '</td></tr>'
nTotAvista += Round(pd->quantidade*pd->preco_unit,2)
nTotAprazo += Round(pd->quantidade*eq->prazo,2)
pd->(dbskip())
EndDo
IF (nSemdesc-nTotal) > 0
cHtml += '<tr><td colspan=7> Total Sem Desconto: ' + Transform(nSemdesc,'@e 9999,999.99') + '</td></tr>'
cHtml += '<tr><td colspan=7> Desconto de: ' + Transform(nSemdesc-nTotal,'@e 9999,999.99') + '</td></tr>'
endif
cHtml += '<tr><td colspan=4> Total do Orçamento: ' + '<td align=right>' + Transform(nTotAvista-nDescTot,'@e 9999,999.99')+'</td>'
cHtml += '<td colspan=2 align=right>' + Transform(nTotAprazo,'@e 9999,999.99') + '</td></tr>'
cHtml += '</table>'
cHtml += '</div></body></html>'
hb_MemoWrit("orcamento.html",cHtml)
Com PDF ZEBRADO etc, etc.... TODAS as firulas desses geradores de relatórios ! Imagens etc, etc, etc e é claro etc!
HTML + CSS é o caminho !
Cereja do bolo!
IF !Empty(cEmail) //Mandar EMAIL PDF vapt, vupt ! Via linha de comando usando o CHROME para gerar o PDF. Fica na pasta Meus Documentos do win.
//VIA DOS usar aspas duplas ' "\Program Files (x86)\Google\Chrome\Application\chrome.exe" ...'
//hb_MemoWrit("comando.bat", cComando)
cArq := hb_GetEnv("USERPROFILE") + "\Documents\" + 'orçamento_' + AllTrim(cEmail)+'.pdf'
cComando := '\Program Files (x86)\Google\Chrome\Application\chrome.exe --headless --disable-gpu --print-to-pdf="' + cArq + '" "' + cDirSist+'orcamento.html"'
hb_processRun( cComando,,@cStdOut,@cStdErr,.T. )
Email(cArq,cSubject,cBody,cEmail,cArq)
//hwg_msginfo(cStdOut)
//hwg_msginfo(cStdErr)
ENDIF
hwg_Shellexecute("orcamento.html","open",,cDirSist,1) //USE HB_PROCESSRUN quem não usa HWGUI !
Depois eu posto a tela como fica. E a Cta PIX para o cafezinho!
Saudações,
Itamar M. Lins Jr.