/**************************************** * Compilar: hbmk2 teste_imp.prg -lhbwin -lxhb ****************************************/ PROCEDURE Main() LOCAL nPrn := 1 LOCAL cFileName := LEFT("EXTRATO_PROVISORIO.TXT"+Space( 60 ),60) LOCAL aPrn := WIN_PRINTERLIST() LOCAL GetList := {} CLS SETMODE(25,80) IF Empty( aPrn ) Alert("Nenhuma impressora Instalada - Encerrando programa") QUIT ENDIF DO WHILE nPrn != 0 CLS @ 0, 0 SAY "Informe um arquivo para impressao" @ 1, 0 SAY "Nome do Arquivo:" GET cFileName PICT "@!K" READ IF LASTKEY()=27 EXIT ENDIF @ 3, 0 SAY "Escolha a impressora" @ 5, 9 TO MaxRow()-9, MaxCol()-9 nPrn := AChoice( 6, 10, MaxRow() - 10, MaxCol() - 10, aPrn, .T.,, nPrn ) IF nPrn != 0 Imprime( cFileName, aPrn[ nPrn ] ) ENDIF ENDDO RETURN ******************************************* Function Imprime(cArq,cPrinter) ******************************************* Local cLinha oPrinter:=Win_Prn():new(cPrinter) oPrinter:Landscape:= .F. oPrinter:FormType:= 9 oprinter:SetPrintQuality(-1) oPrinter:Copies:= 1 oPrinter:Create() oPrinter:StartDoc("Teste") nHandler := FOpen( cArq ) oPrinter:newline() While HB_FReadLine( nHandler, @cLinha ) = 0 t_:=AT(CHR(12)+CHR(13),cLinha) If t_>0 cLinha:=LEFT(cLinha,t_-1) EndIf oPrinter:TextOut( HB_OemToAnsi( cLinha ), .t. ) If t_>0 oPrinter:NewPage() // inicia nova pagina oPrinter:newline() oPrinter:newline() EndIf EndDo oPrinter:EndDoc() oPrinter:Destroy() Return Nil oPrinter:SetFont("Courier New",13,{3,-50},0,.F.,.F.) // Comprimida