Jump to content
Fivewin Brasil

Imprimir Arquivo *.TXT no Fivewin?


kapiaba

Recommended Posts

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.

 

Link to comment
Share on other sites

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********************************** 
******************************************************************************** 
 

Link to comment
Share on other sites

 

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...