kapiaba Posted September 3, 2020 Report Share Posted September 3, 2020 Galera, como eu faço pra imprimir um Imprimir Arquivo *.TXT no Fivewin? E também, como faço para transformar esse *.TXT em *.PDF JOAO.TXT -> Imprimir direto na Impressora. JOAO.TXT -> Transformar em PDF para enviar por email por example. Muchas gracias, many thanks, muito obrigado. Quote Link to comment Share on other sites More sharing options...
ADutheil Posted September 4, 2020 Report Share Posted September 4, 2020 Eu tentataria alguma coisa com a classe TPrinter e um loop com hb_fReadLine para imprimir e com a classe FWPdf para gerar um PDF. Quote Link to comment Share on other sites More sharing options...
kapiaba Posted September 4, 2020 Author Report Share Posted September 4, 2020 Blz, garoto? me ajuda ahi, baixe esse modelo e modifique para a sua ideia por favor. Anexo: IMPTXT.PRG ARQ.TXT Baixe do meu Mega Upload, e modifique a gosto, susgestões são bem vindas. Many thanks. https://mega.nz/file/UV11VD7T#pQ8t6SMUxTtyumR9WMNLO9C7LjM7Q2eVGPYZP6aTQN0 Abs. Quote Link to comment Share on other sites More sharing options...
ADutheil Posted September 4, 2020 Report Share Posted September 4, 2020 Não entendi, parece estar funcionando bem. Quote Link to comment Share on other sites More sharing options...
kapiaba Posted September 4, 2020 Author Report Share Posted September 4, 2020 Sim meu garoto, mas eu queria ver com a sua ideia, tendeu? Gostaria de ter opções variadas, pode fazer isso para nosotros? Thanks. Quote Link to comment Share on other sites More sharing options...
Frazato Posted September 4, 2020 Report Share Posted September 4, 2020 Tarde! Uso assim, todos os relatorio gero um Txt e importo para o DBF e gero o PDF. Compilo utilizado a pdf.lib. Frazato #include "inkey.ch" #include "cxwin.ch" #include "jaf.ch" Function Main() setcursor(0) REQUEST DBFCDX RDDSETDEFAULT("dbfcdx") DBSETDRIVER("dbfcdx") cARQ :='c:\temp\rela0008.txt' Sele 1 use c:\temp\Preview alias Preview GERA_PDF(cARQ) Return nil ******************* FUNC GERA_PDF(cARQ,cVisualiza) ******************* Private AMSG, CIMG PRIVATE oDlgHabla:=NIL AMSG := {} set(105,1) set(106,1) IF cARQ=Nil cARQ="TEMP.PRN" Endif centra(24,"Aguarde Gerando Documento PDF...") nSeq := 0 Do While ! Eof() nSeq++ If ! File("p:\temp\JAF_"+StrZero(nSeq,4)+'.PDF') cFILE3 := "p:\temp\JAF_"+StrZero(nSeq,4)+'.PDF' Exit Endif If nSeq >=9999 Alerta("Faca a limpeza da pasta p:\temp\") Endif Enddo Sele Preview nOpcao := AlertJAF("DESTINO"+; ' ',{"### Normal ###",; "### Compactado DRE ###",; "### Romaneio ###" },"WW+/BR+,BB+/N" ) If nOpcao==1 PdfNew(cFile3,nFonte,842,595,1,1,,,) Elseif nopcao ==2 PdfNew(cFile3,nFonte,595,842,1,1,,,) Elseif nopcao ==3 nFonte := 12 PdfNew(cFile3,nFonte,842,595,1,1,,,) Endif //--- Atual ate 07.02.2014 //PdfNew(cFile3,8,842,595,1,1,,,) // - 06-06-2019 //PdfNew(cFile3,7,842,595,1,1,,,) *PdfNew(cFile3,nFonte,842,595,1,1,,,) *Pdfsetfont( _cFont, _nType, _nSize, cId ) cFile := "fundo.jpg" PdfStartPage( {""} , .T. ) //PdfImage(cFile,0,0) dbgotop() cCONT=0 cQuebra:= .f. Do while !eof() *cLinha := Linha // Busca linha de impressao cLinha := l001+l002+l003+l004+l005+l006+l007+l008+l009+l010 cCONT=cCONT+1 cLinha := StrTran(cLinha,'Ä','=') Aadd(AMSG,cLinha) I=0 For I:= 1 to Len(cLinha) //---- Ajusta caracter If Substr(cLinha,i,1)==Chr(12) cQuebra:= .t. Exit Endif Next if cQuebra==.t. PdfDrawPage( AMSG ) PdfEndPage() PdfStartPage( {""} , .T. ) cQuebra:= .f. AMSG := {} // Sei-la para quebra a pagina corretamente conforme o cabecario cCONT=0 ENDIF dbskip() enddo PdfDrawPage( AMSG ) PdfEndPage() PdfEnd() IF oDlgHabla#NIL oDlgHabla:CLOSE() ENDIF *If cVisualiza=="S" * Abre_aqrquivo( cFile3 ) *Else Alerta('Criado arquivo....'+cFile3) Return cFile3 *Endif return nil ******************************************************************************** ***************INCIO DA FUNCAO DE ABRIR ARQUIVOS******************************** ******************************************************************************** // Open help file with associated viewer application FUNCTION Abre_aqrquivo( cHelpFile ) LOCAL nRet, cPath, cFileName, cFileExt HB_FNameSplit( cHelpFile, @cPath, @cFileName, @cFileExt ) nRet := _OpenHelpFile( cPath, cHelpFile ) RETURN nRet #pragma BEGINDUMP // #pragma comment( lib, "shell32.lib" ) #include "hbapi.h" #include <windows.h> HB_FUNC( _OPENHELPFILE ) { HINSTANCE hInst; LPCTSTR lpPath = (LPTSTR) hb_parc( 1 ); LPCTSTR lpHelpFile = (LPTSTR) hb_parc( 2 ); hInst = ShellExecute( 0, "open", lpHelpFile, 0, lpPath, SW_SHOW ); hb_retnl( (LONG) hInst ); return; } #pragma ENDDUMP ******************************************************************************** ***************FIM DA FUNCAO DE ABRIR ARQUIVOS********************************** ******************************************************************************** Quote Link to comment Share on other sites More sharing options...
ADutheil Posted September 4, 2020 Report Share Posted September 4, 2020 Citar Sim meu garoto, mas eu queria ver com a sua ideia, tendeu? Gostaria de ter opções variadas, pode fazer isso para nosotros? Thanks. Minha solução seria muito parecida com a sua. #include "FiveWin.ch" FUNCTION Main() LOCAL nEntr, cBuff, OPRN, OFONT, NLIN nEntr:= fOpen( "ARQ.txt" ) PRINTER oPrn NAME "Imprimindo um TXT" PREVIEW MODAL DEFINE FONT oFont NAME "COURIER NEW" SIZE 0, - 8 OF oPrn oPrn:SetPage( 9 ) // A4 oPrn:SetPortrait() // Vertical PAGE nLin := 1 WHILE hb_fReadLine( nEntr, @cBuff, chr(10) ) == 0 SYSREFRESH() oPrn:CmSay( nLin += .4, 1, cBuff, oFont ) IF nLin > 25 nLin := 1 ENDPAGE PAGE ENDIF ENDDO ENDPAGE ENDPRINT fClose( nEntr ) oFont:End() RETURN NIL Quote Link to comment Share on other sites More sharing options...
kapiaba Posted September 5, 2020 Author Report Share Posted September 5, 2020 Very good, amanhã, vou testar. Compilo utilizado a pdf.lib. Frazato, #include "cxwin.ch" #include "jaf.ch" Frazato, onde acho a PDF.LIB? E estes Includes, são necessários? Obg. abs. Quote Link to comment Share on other sites More sharing options...
kapiaba Posted September 5, 2020 Author Report Share Posted September 5, 2020 Resposta do Mister Nages: http://forums.fivetechsupport.com/viewtopic.php?f=6&t=39337&p=234703#p234703 Abs Quote Link to comment Share on other sites More sharing options...
ADutheil Posted September 5, 2020 Report Share Posted September 5, 2020 Vivendo e aprendendo. A classe gera um PDF automaticamente em função da extensão do arquivo de destino. Quote Link to comment Share on other sites More sharing options...
Frazato Posted September 5, 2020 Report Share Posted September 5, 2020 10 horas atrás, kapiaba disse: Very good, amanhã, vou testar. Compilo utilizado a pdf.lib. Frazato, #include "cxwin.ch" #include "jaf.ch" Frazato, onde acho a PDF.LIB? E estes Includes, são necessários? Obg. abs. Utilizo as libs hbhpdf.lib e pdf.lib não e necessario os arquivos includes, esqueci de retirar.. Frazato Quote Link to comment Share on other sites More sharing options...
kapiaba Posted September 5, 2020 Author Report Share Posted September 5, 2020 Perfeito... Perfect!!! #Include "FiveWin.ch" FUNCTION Main() LOCAL WNOMBREARQPDF MsgRun( "GENERANDO ARCCHIVO *.PDF...", ; "Por Favor, Aguarde... ", ; { || WinExec( Generar_PDF() ), 3 } ) // Perfect, mister Nages, Thank You IF FILE( "ARCHIVO.PDF" ) WNOMBREARQPDF := "c:\fwh\samples\archivo.pdf" ShellExecute( 0, "Print", WNOMBREARQPDF,,, 3 ) ENDIF RETURN NIL FUNCTION Generar_PDF() LOCAL cText := MEMOREAD( "c:\fwh\samples\arq.txt" ) LOCAL oPrn, oFont PRINT oPrn FILE "archivo.pdf" DEFINE FONT oFont NAME "COURIER NEW" SIZE 0,-10 OF oPrn WHILE .NOT. EMPTY( cText ) SYSREFRESH() CURSORWAIT() PAGE @ 1,1 PRINT TO oPrn TEXT @cText SIZE 7,10 INCHES FONT oFont ENDPAGE ENDDO ENDPRINT RELEASE FONT oFont CURSORARROW() RETURN NIL Thanks to all. Quote Link to comment Share on other sites More sharing options...
kapiaba Posted September 5, 2020 Author Report Share Posted September 5, 2020 http://forums.fivetechsupport.com/viewtopic.php?f=6&t=39337 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.