O meu relatorio é impressão de contra-cheque onde eu imprimo 2 contracheques por pagina (inclusive eu preciso imprimir a linha 88 mais não consigo porque só tem capacidade para imprimir 87 linhas por pagina.
Utilizo a função abaixo.
Código: Selecionar todos
FUNCTION Imprime( cPrinter, cArq, TAMLIN, ver, tampag )
////////////////////////////////////////////////////////////////////////////////
local cTexto, nLinhas, nA, cLinha, nB // oPrinter := win32prn():New(cPrinter)
LOCAL oPrinter := win32prn():new(getdefaultprinter())
local Prn
local nPrn:=1
local aPrn:= GetPrinters()
oPrinter:Landscape := .F.
oPrinter:FormType := 9 // A4
oprinter:SetPrintQuality(-1) // qualidade da impressão
oPrinter:Copies := 1
if tampag = nil
tampag := 58
endif
if empty(aPrn)
mens(cor5,"NÆo encontrou impressoras instaladas....Favor Verificar a Impressora !!!")
return NIL
endif
if cPrinter = "printfileraw"
TAM = LEN(PRTPADRAO)
IF SUBSTR(PRTPADRAO,1,15) <> SPACE(15) .AND. SUBSTR(PRTPADRAO,TAM,1) = 'S'
Prn:=TRIM(SUBSTR(PRTPADRAO,1,TAM-1))
ELSE
Prn:=getdefaultprinter()
ENDIF
ret:=printfileraw(Prn,cArq)
@ maxrow()-8,10 say 'retorno printfileraw: ' + str(ret) + ' ' + PRN + ' ' + carq
return
endif
if ver
fAbreJanela("Seleciona Impressora",18,15,25,85)
do while !empty(nprn)
// cls
// @ 0,0 say 'Teste de classe Win32Prn(). Escolha a impressora. ESC p/sair'
// @ 1,0 to maxrow(), maxcol()
nPrn := achoice(19,16,24,84,aPrn)
if lastkey() = 27
fFechaJanela()
return
endif
if !empty(nprn)
oPrinter := win32prn():new(aPrn[nPrn])
exit
endif
enddo
fFechaJanela()
endif
IF !oPrinter:Create()
mens(cor5,"Atenção !!! O Sistema encontrou um Problema ao Tentar Executar Create().")
return NIL
endif
IF ! oPrinter:StartDoc(cArq)
mens(cor5,"Atenção !!! O Sistema encontrou um Problema ao Tentar executar StartDoc()")
return NIL
endif
if TAMLIN > 80
IF TAMPAG > 70
oprinter:LineHeight := int(oprinter:PixelsPerInchy/8)
oPrinter:SetFont(,10,{-1,17},0,.F.,.F.)
elseIF TAMPAG > 60
oprinter:LineHeight := int(oprinter:PixelsPerInchy/6)
oPrinter:setfont(,,17,,,,255)
ELSE
oPrinter:setfont(,,17,,,,255)
ENDIF
else
IF TAMPAG > 70
oprinter:LineHeight := int(oprinter:PixelsPerInchy/8)
oPrinter:setfont(,9,10,,,,255)
elseIF TAMPAG > 60
oprinter:LineHeight := int(oprinter:PixelsPerInchy/6)
oPrinter:setfont(,,11,,,,255)
ELSE
nFont := 12
oPrinter:SetFont('Courier New',12,{1,nFont}, 0, .F., .F.)
ENDIF
endif
oPrinter:TextOut( space(TAMLIN), .T. )
cTexto := memoread( cArq )
nLinhas := mlcount( cTexto, TAMLIN, 1, .F. )
nConta := 0
nconta = 0
for nA := 1 to nLinhas
cLinha := memoline( cTexto, TAMLIN, nA, 1, .F. )
if nA = 1 .and. substr(clinha,0,2) = chr(12)+chr(13)
loop
endif
for nB := 0 to TAMLIN
if substr(clinha,nB,2) = chr(12)+chr(13)
IF nconta > TAMPAG
exit
endif
WHILE NCONTA <= TAMPAG
oPrinter:Newline()
NCONTA = NCONTA + 1
enddo
exit
endif
next
IF NCONTA >= TAMPAG
oPrinter:NewPage()
oPrinter:Newline()
oPrinter:Newline()
nConta=0
else
oPrinter:TextOut( cLinha, .T. )
nConta=nConta+1
endif
next
oPrinter:EndDoc()
oPrinter:Destroy()
RETURN NIL
Obrigado
José Malta Lócio


