Les envío el código que utilizé por si a alguien le interesa.
Code: Select all
function creapdfcc(aCcli,nclia,lprove,cNapea,cMail)
local dresult := DEHASTA()
local cImpdos
local oprn
local nsaldo := 0
local nvalor := 0
local z := 0
local cPath := "E:\fivehme\" + alltrim(cNapea) +".pdf"
local oPdf
local ntotal := 0
n := 2.9
opdf := tpdf():new(cPath)
TITULO(oPdf)
for z = 1 to len(aCCli)
if aCCli[z,1] <= dresult[1]
nsaldo := aCcli[z,5]
nvalor := z +1
else
exit
endif
next
titulo1(oPdf ,cnapea,dresult)
if !empty(nsaldo)
oPdf:Pdfatsay(("Saldo al: " + dtoc(dresult[1])),cm2dpi(n+=.4 ),cmAncho(3.4))
oPdf:Pdfatsay(transform(nsaldo,'@E 9,999,999.99'),cm2dpi(n),cmAncho(19))
endif
iif(empty(nvalor), nvalor := 1, nvalor)
for z = nvalor to len(aCCli)
oPdf:Pdfatsay(transform(aCcli[z,1],"@d"),cm2dpi(n+.4),cmAncho(1))
oPdf:Pdfatsay(substr(oemtoansi(aCcli[z,2]),1,22) ,cm2dpi(n+.4),cmAncho( 3.4))
if !empty(aCcli[z,3])
oPdf:Pdfatsay(transform(aCcli[z,3],"@e 999,999.99") ,cm2dpi(n+=.4 ),cmAncho(9 ),.T. )
else
oPdf:Pdfatsay( transform(aCcli[z,4],"@e 999,999.99"),cm2dpi(n+=.4 ),cmAncho(14 ),.T. )
endif
oPdf:Pdfatsay(transform(aCcli[z,5],'@E 9,999,999.99'),cm2dpi(n ),cmAncho(19),.T. )
// oPdf:Pdfatsay(StrZero1(aCcli[z,5],12),cm2dpi(n ),cmAncho(19),.T. ) no funciona así
if n >= 25.4 .or. z = len(aCcli) .or. aCcli[z,1] > dresult[2]
oPdf:Pdfatsay(replicate("_",115),cm2dpi( n+=.4 ),10,.T.)
oPdf:Pdfatsay(("Estado de cta. cte. al " + transform(aCcli[z,1],"@d")),cm2dpi( n+=.4 ),cmAncho(3.4),.T.)
oPdf:Pdfatsay(transform(aCcli[z,5],'@E 9,999,999.99'),cm2dpi(n ),cmAncho(19))
oPdf:Pdfatsay(replicate("_",115),cm2dpi( n+=.4 ),10,.T.)
if aCcli[z,1] > dresult[2]
exit
endif
IF z != len(aCcli)
opdf:Pdfclosepage()
opdf:Pdfnewpage("A4","P")
n := 2.2
titulo1(oPdf, cNapea,dresult)
oPdf:Pdfatsay(("Estado de cta. cte. al " + transform(aCcli[z,1],"@d")),cm2dpi( n+=.4 ),cmAncho(3.4),.T. )
oPdf:Pdfatsay(transform(aCcli[z,5],'@E 9,999,999.99'),cm2dpi(n ),cmAncho(19),.t.)
endif
endif*/
next
opdf:Pdfclosepage()
opdf:pdfclose()
msginfo("Archivo creado con éxito","Aviso del sistema")
if !empty(cmail)
correo(cMail,,("Enviamos resumen de cuenta desde " + transform(dresult[1],"@d") + " hasta " + transform(dresult[1],"@d") ),"Resumen de cuenta", alltrim(cPath ) )
endif
return .t.
/*******************************************************************************/
STATIC FUNCTION titulo(oPdf)
opdf:Pdfnewpage("A4","P")
opdf:Pdfimage("e:\tpdf\logoc1.jpg", cm2dpi(2.5), 0,85,66)
oPdf:Pdfsetfont( "TIMES", BOLD, 10)
opdf:Pdfatsay("QUÍMICA MEGA SA",cm2dpi( .7 ),100,.T.)
oPdf:Pdfsetfont( "TIMES",NORMAL, 10)
oPdf:Pdfatsay("Matanza 1456/58",cm2dpi( 1.2 ),100,.T.)
oPdf:Pdfatsay("Avellaneda-Pcia Bs As",cm2dpi( 1.6 ),100,.T.)
oPdf:Pdfatsay("T.E.: 4289-2700(Rotativas)",cm2dpi( 2.0 ),100,.T.)
oPdf:Pdfatsay(replicate("_",115),cm2dpi( 2.5 ),10,.T.)
return nil
/*******************************************************************************/
static function titulo1(oPdf, cNapea,dresult)
local ctitu := "RESUMEN DE CUENTA CORRIENTE"
local cDesde := "Desde el: " + dtoc(dresult[1])
local cHasta := "Hasta el: " + dtoc(dresult[2])
oPdf:Pdfatsay(ctitu,cm2dpi(n+=.1 ),210)
oPdf:Pdfatsay(cNapea ,cm2dpi(n +=.4),10 )
oPdf:Pdfatsay(cDesde ,cm2dpi(n +=.4), 10)
oPdf:Pdfatsay(cHasta ,cm2dpi(n +=.4),10 )
oPdf:Pdfatsay(replicate("_",115),cm2dpi(n ),10)
return nil
/*******************************************************************************/