Sim estou gerando a impressão a partir de um arquivo texto, visto que já tenho todos os relatorios montados como abaixo:
TENHO PROBLEMA COM A LARGURA DO RELATORIO, MUDEI oprinter:FormType :=1 //9 //9 //12 // letter = 1 , USEI 9, 12, 18, 1 E TODOS SÃO IGUAIS NÃO ALTEROU NADA NA LARGURA DO FORMULARIO e TBEM O PROBLEMA DE O RELATORIO EJECTAR A FOLHA ANTES DE IMPRIMIR.
Ps: CAIXA ALTA, é desespero, hehehehe, pois se eu tiver que mudar todos os relatorios para retirar 5 caracter por linha, estarei lascado. hehhee.
Código: Selecionar todos
Static Procedure Imprime
ShowWait(,,"Imprimindo Na Sa¡da Padr„o...")
c_Imprime() //esta função gera o arquivo abaixo em texto
WPag:=0
Set Device To Print
Set Printer To &cP_Printer.
DbGoTop()
Do While !Eof()
Cabecalho(,Titulo,"Per¡odo De.: " +DtoC(WInicial)+" A "+DtoC(WFinal) +OrdemArq+If(wJR=.T.," Com Juros",""))
If wPag=1
@ PRow()+01,00 Say "Cliente...: "+wCod +" "+If(WCod #"99999",Abreviate(NOME,30),"Clientes Em Geral")
@ PRow()+01,00 Say "Vendedor..: "+wVend +" "+If(WVend #"9999" ,Abreviate(CDUP0600->VENDEDOR,30),"Vendedores Em Geral")
@ PRow()+01,00 Say "Caixa.....: "+wCx +" "+If(WCx #"99" ,Abreviate(CDOC0400->NOME,30),"Caixas Em Geral")
@ PRow()+01,00 Say "Cidade....: "+wCid +" "+If(WCid #"9999" ,Abreviate(CDUP0800->CIDADE,30),"Cidades Em Geral")
@ PRow()+01,00 Say "Cobrador..: "+wCobra+" "+If(WCobra#"9999" ,Abreviate(CDOC0600->COBRADOR,30),"Cobradores Em Geral")
@ PRow()+01,00 Say "Mercadoria: "+wMerc +" "+If(WMerc#"9999999","Mercadoria Especifica","Mercadorias Em Geral")
@ PRow()+01,00 Say Repl("Ä",80)
EndIf
If wType=="E".And.wOd#"C"
// @ PRow()+01,00 Say CHR(15)+"Codigo Cliente Documento Pc/Qt Nota Vend Banc Emissao S Vencimento Nat Valor Basico% N_Basico% Obs "+CHR(18) //tirei por causa dos CHR, DEIXEI SEM PARA COMEÇO
@ PRow()+01,00 Say "Codigo Cliente Documento Pc/Qt Nota Vend Banc Emissao S Vencimento Nat Valor Basico% N_Basico% Obs "
ElseIf wType=="E".And.wOd=="C"
// @ PRow()+01,00 Say CHR(15)+"Codigo Cliente Documento Pc/Qt Nota Vend Banc Cobran‡a S Vencimento Nat Valor Endere‡o do cliente "+CHR(18)
@ PRow()+01,00 Say "Codigo Cliente Documento Pc/Qt Nota Vend Banc Cobran‡a S Vencimento Nat Valor Endere‡o do cliente "
Else
// @ PRow()+01,00 Say CHR(15)+"Codigo Cliente Documento Pc/Qt Nota Vend Banc Emissao S Vencimento Nat Valor pagamento Valor pago"+CHR(18)
@ PRow()+01,00 Say "Codigo Cliente Documento Pc/Qt Nota Vend Banc Emissao S Vencimento Nat Valor pagamento Valor pago"
EndIf
@ PRow()+01,00 Say Repl("Ä",80)
While !Eof() .And. PRow() < 60
ShowWaitProc(.T.)
@ PRow()+01,00 Say "" //Chr(15) DESATIVEI OS CHR
@ PRow() ,PCol() Say CODIGO
@ PRow() ,PCol()+01 Say Abreviate(NOME,20)
@ PRow() ,PCol()+01 Say NDOC
@ PRow() ,PCol()+01 Say NPARC+"/"
@ PRow() ,PCol() Say QTE
@ PRow() ,PCol()+01 Say Left(NOTA,15)
@ PRow() ,PCol()+01 Say VEND
@ PRow() ,PCol()+01 Say BANCO
@ PRow() ,PCol()+01 Say If(wType=="E".And.wOd=="C",DT_COBRA,DT_EMI)
@ PRow() ,PCol()+01 Say SITUACAO //Left(ShowSit(SITUACAO),5)
@ PRow() ,PCol()+01 Say DT_VENC
@ PRow() ,PCol()+01 Say Left(ShowNat(TP_DOC),2)
@ PRow() ,PCol()+01 Say VALOR Pict "@E 99,999,999.99"
If wType=="E".And.wOd#"C"
@ PRow() ,PCol()+01 Say BASICO //Pict "@E 999.9999%"
@ PRow() ,PCol()+01 Say DESCONTO //Pict "@E 999.9999%"
@ PRow() ,PCol()+01 Say Abreviate(OBS,05)
ElseIf wType=="E".And.wOd=="C"
@ PRow() ,PCol()+01 Say Abreviate(ENDERECO,25)
Else
@ PRow() ,PCol()+01 Say DT_PAGTO
@ PRow() ,PCol()+01 Say VR_PAGO Pict "@E 999,999,999.99"
EndIf
// @ PRow() ,PCol() Say Chr(18)
DbSkip(1)
End
If !Eof()
Rodape()
EndIf
EndDo
@ PRow()+01,00 Say Repl("Ä",80)
@ PRow()+01,00 Say "Total:"
@ PRow() ,Pcol()+82 Say VParc Pict "@E 999,999,999,999.99"
If wType=="L"
@ PRow(),PCol()+8 Say VPago Pict "@E 999,999,999,999.99"
EndIf
//@ PRow() ,120 Say "" //Chr(18)
Rodape()
Set Printer To
Set Device To Screen
Set Cursor Off
CloseWindow()
e_Imprime() //ESTA FUNCÇÃO LE O ARQUIVO TEXTO EXPECIFICO E MANDA ELE PARA A IMPRESSORA
Return
Function c_Imprime
cP_Printer:=wD_Retorno+"IMPRESS.PRN" //POR ENQUANTO UM UNICO NOME, MAS TEREI QUE FAZER DIFERENTE PARA CADA MAQUINA PARA PODER USAR EM REDE
Return .T.
Function e_Imprime(aLn)
aLn:=If(aLn=Nil,132,aLn)
If Right(cP_Printer,11)=="IMPRESS.PRN"
If MyPrinters() //esta funcao escolhe qual impressora que eu quero que esta instalada o pc e passa na variavel de sistema cPrinter para a função abaixo
ImprimeGeral(wD_Retorno+"IMPRESS.PRN",aLn) //ESTA É A FUNCAO
FErase(wD_Retorno+"IMPRESS.PRN")
EndIf
cP_Printer:="Lpt1"
EndIf
Return .T.
Function ImprimeGeral(cArq,tamrel) // arquivo e tamanho da linha
Local cTexto, nLinhas, nA, cLinha, oPrinter := win32prn()
oPrinter:New(cPrinter) //pega a escolhida por MyPrinter
oPrinter:Landscape:=.F. //VERTICAL .T. HORIZONTAL
oPrinter:FormType :=1 //9 //9 //12 // letter = 1
oPrinter:Copies :=1
oPrinter:Create()
oPrinter:StartDoc()
oPrinter:SetDefaultFont()
If TamRel>80
oPrinter:SetFont(,,20,{3,-50}) //ESTOU TESTANDO COM ESTA SUPER COMPRIMIDA E NADA DEU CERTO, CONTINUA ULTRAPASSANDO 5 CARACTERES PARA LINHA DE BAIXO.
Else
oPrinter:SetFont(,,06,,,,255)
EndIf
oPrinter:TextOut(Space(tamrel),.T.)
cTexto :=MemoRead(cArq)
nLinhas :=mLCount(cTexto,tamrel,1,.F.)
For nA := 1 To nLinhas
cLinha:=MemoLine(cTexto,tamrel,nA,1,.F.)
If Left(AllTrim(cLinha),1)==Chr(12) //SALTO_PAGINA
oPrinter:NewPage()
Else
oPrinter:TextOut(cLinha,.T.)
EndIf
Next
oPrinter:EndDoc()
oPrinter:Destroy()
Return NIL
Function MyPrinters()
Local aRet:=.F.
Local nPrn:=1
Local aPrn:=GetPrinters()
Local Ls:=03,Cs:=20,Li:=15,Ci:=60
Set Key -5 To
If !Empty(aPrn)
OpenWindow(Ls,Cs,Li,Ci,"Escolha a impressora","","GR+/R")
If ((nPrn:=Achoice(Ls+3,Cs+2,Li-1,Ci-2,aPrn,.T.,"UserFuncTec"))!=0)
cPrinter:=aPrn[nPrn]
If cPrinter=="Imprimir para arquivo"
iFile() //gera em nome de texto para ser enviado via email
EndIf
aRet:=.T.
EndIf
CloseWindow()
Else
ShowMessage(,,"NÆo h impressoras instaladas",0)
EndIf
Set Key -5 To MyPrinters()
Return aRet
Grato por enquanto.