harbour boleto

Projeto [x]Harbour - Compilador de código aberto compatível com o Clipper.

Moderador: Moderadores

Abel
Usuário Nível 3
Usuário Nível 3
Mensagens: 332
Registrado em: 14 Mar 2012 13:16
Localização: sao paulo / sp

harbour boleto

Mensagem por Abel »

ola pessoal,
tenho diversos problemas que to aos poucos resolvendo um a um desde que mudei de clipper para o harbour. Um dos problemas é quanto a cobranca, pois faco boletos pelo BB, carteira 17 19, (banco emite, banco envia) e o maior problema é o cliente nao receber ou ele ter o CNPJ cadastrado do DDA (novo servico que os banco inventaram que quando ativo no CNPJ os bancos nao emitem boletos de papel para o CNPJ) pois o mesmo autorizado que fosse eletronico. Muitas vezes o cliente nem sabe o que é DDA.

Minha ideia, era o proprio sistema abrir uma opcao "gerar boleto", o proprio cliente emite na impressora dele, e paga, e eu controlo isso pelo arquivo de retorno.
Ja sei que vou ter que usar outra carteira junto ao banco...e configurar o meu proprio sistema para controlar o retorno.

Minha duvida, é como emitir o boleto atraves do meu sistema. Li varias postagens sobre o Harbour Boleto, mas nao achei ainda onde fazer o download e por onde comecar meus testes ...

Se alguem puder me dar algumas dicas, agradeço.
ABEL
Avatar do usuário
sygecom
Administrador
Administrador
Mensagens: 7131
Registrado em: 21 Jul 2006 10:12
Localização: Alvorada-RS
Contato:

harbour boleto

Mensagem por sygecom »

Olá Abel,
Você terá que baixar o HarbourBoleto direto do CVS usando o TORTOISE CVS
Endereço para ser usado no Tortoise
:pserver:anonymous@harbourboleto.cvs.sourceforge.net:/cvsroot/harbourboleto

Ou no link abaixo(o correto é baixar usando o CVS)
http://www.fivewin.com.br/Dicas/881xhbboleto.zip
Leonardo Machado
xHarbour.org + Hwgui + PostgreSql
Abel
Usuário Nível 3
Usuário Nível 3
Mensagens: 332
Registrado em: 14 Mar 2012 13:16
Localização: sao paulo / sp

harbour boleto

Mensagem por Abel »

sygcom, baixei pelo link porque nao sei o que é tortoise cvs.
é a primeira vez que vejo este termo...pois sou novo no harbour, pois apenas usava o clipper e nao tinha a minima noçao do que o harbour era capaz.

vc pode me passar algumas dicas de como usar o tortoise, e o quq é cvs ?

quanto ao download que fiz, pelo que li nos posts e entendi, se eu criar o bol.ini e rodar o hboleto.exe ele gera o boleto de acordo com as configuracoes do bol.ini em html.
fiz inclusive um teste de 1,00 e paguei para ver se da certo.. rs rs

por enquanto, valeu !!!

ABEL
Abel
Usuário Nível 3
Usuário Nível 3
Mensagens: 332
Registrado em: 14 Mar 2012 13:16
Localização: sao paulo / sp

harbour boleto

Mensagem por Abel »

sygecom, procurei na net e baixei o TORTOISE CVS

mas nao consegui utiliza-lo para baixar o harbour boleto conforme vc disse no post anterior.

pelo link q baixei o harbour boleto, fiz diversos testes e gera o boleto normal pelo bol.ini, o problema é quando faco pelo BB banco 001, meu convenio é de 7 digitos e ele nao esta adaptado para montar o nosso numero e nem o codigo barra de acordo com as especificacoes do BB. tentei alterar e compilar, mas tb nao consegui compilar pelo harbour 3.1 nigthy.

Abel
lucimauro
Usuário Nível 3
Usuário Nível 3
Mensagens: 465
Registrado em: 21 Set 2004 21:02
Localização: Sobral-CE

harbour boleto

Mensagem por lucimauro »

Eu tambem tenho o mesmo problema com harbour boleto,ate ja compilei com harbour 3.0 + MinGw, so que não gera o boleto completo e quando vou visualizar no explorer pede para ajustar as margens.

Espero que algun possa ajudar a egente.
Imatech
Usuário Nível 3
Usuário Nível 3
Mensagens: 350
Registrado em: 24 Ago 2010 23:48
Localização: Goiânia-GO

harbour boleto

Mensagem por Imatech »

Olá Abel !


Para BB: Convenio com 7 digitos e NossoNumero com 18+DV

Ajustar: oBoleto.prg

Código: Selecionar todos

*------------------------------------------------------------------*
* Ajustes/Modificações por:
* M., Ronaldo 10/08/2012
*------------------------------------------------------------------*

...
METHOD Execute() CLASS oBoleto
...
   LOCAL cAux := ''
...
      CASE ::cCodBco == "001" // Brasil
         IF LEFT( cCarteira, 2) $ "(16#18)"
           *------------------------------------------------------------------*
           * COBRANÇA SEM REGISTRO: 18 Digitos para NN
           * Autor: M., Ronaldo 10/08/2012
           *------------------------------------------------------------------*
           cAux := LEFT( ::cCDPF, 7 )
           ::cCDPF := STRZERO( VAL( LEFT( cAux, 6 ) ), 6 )

           cAux  := ::cCDPF + SUBSTR( cAux, 7, 1 )
           ::cNossoNumero := cAux + STRZERO( VAL( ::cNossoNumero ), 10 )

           cAux := '-' + DC_Mod11( ::cCodBco, 9, .F., ::cNossoNumero, .F.)
           cNsNm := ::cNossoNumero + cAux

           cAux := REPL( '0', 6)
           cCpoLivre := cAux + ::cNossoNumero + ::cCarteira //

         ELSE
           *------------------------------------------------------------------*
           * OUTRAS: 11 Digitos para NN
           *------------------------------------------------------------------*
            ::cCDPF        := STRZERO(VAL(::cCDPF),6)
            cCarteira      := STRZERO(VAL(cCarteira),2)
            ::cNumCC       := STRZERO(VAL(::cNumCC),8)
            ::cNossoNumero := STRZERO(VAL(::cNossoNumero),5)
            ::cDGNN        := DC_Mod11(::cCodBco,9,.F.,::cCDPF+::cNossoNumero, .F.)
            cNsNm          := TRANSFORM(::cCDPF+::cNossoNumero,"@R 99.999.999.999")+"-"+::cDGNN
            cCpoLivre      := ::cCDPF+::cNossoNumero+cNumAgencia+::cNumCC+cCarteira
         ENDIF
...



Impressão HTML
Ajustar: htmlprint.prg

Código: Selecionar todos

*------------------------------------------------------------------*
* Ajustes/Modificações por:
* M., Ronaldo 10/08/2012
*------------------------------------------------------------------*
#include "hbclass.ch"
#include "common.ch"

#command DEFAULT <param> := <val> [, <paramn> := <valn> ];
=> ;
         <param> := IIF(<param> = NIL, <val>, <param> ) ;
         [; <paramn> := IIF(<paramn> = NIL, <valn>, <paramn> ) ]

#DEFINE OLECMDID_PRINT 6
#DEFINE OLECMDEXECOPT_PROMPTUSER 1
#DEFINE LECMDEXECOPT_DONTPROMPTUSER 2

#DEFINE OLECMDF_SUPPORTED 1
#DEFINE OLECMDF_ENABLED 2

#DEFINE READYSTATE_COMPLETE 4
#DEFINE MAX_TIME 30

#define HKEY_LOCAL_MACHINE  0
#define HKEY_CLASSES_ROOT   1
#define HKEY_CURRENT_USER   2
#define HKEY_CURRENT_CONFIG 3

#ifndef HKEY_LOCAL_MACHINE
#define HKEY_LOCAL_MACHINE  4
#endif

#define HKEY_USERS          5

#define VERSION             "1.0.01"

STATIC IEHeader
STATIC IEFooter
STATIC IEMarginBottom
STATIC IEMarginLeft
STATIC IEMarginRight
STATIC IEMarginTop
STATIC IEKey  := "Software\Microsoft\Internet Explorer\PageSetup"

STATIC WB
STATIC PR

STATIC HP

//--------------------------------------------------------------------------------------------//
FUNCTION PrintHTML(cURL,cPrinter,lPrevIew,lPromptPrint,lPrintHtml,cHeader,cFooter)

   DEFAULT lPrintHtml   := .T.
   DEFAULT lPreview     := .F.
   DEFAULT lPromptPrint := .F.
   DEFAULT cPrinter     := Win_PrinterGetDefault()
   DEFAULT cFooter      := ""
   DEFAULT cHeader      := ""

   IF (HP==NIL)
      HP := HTMLPRINT():NEW()
   ENDIF

   HP:PrintUrl     := cURL
   HP:lPreview     := lPreview
   HP:lPromptPrint := lPromptPrint
   HP:lPrintHtml   := lPrintHtml
   HP:PrinterName  := cPrinter
   HP:Footer       := cFooter
   HP:Header       := cHeader

   HP:Print()
   HP:Close()

RETURN .T.
//--------------------------------------------------------------------------------------------//

CLASS HTMLPRINT

   DATA PrinterName
   DATA Orientation            //TO DO  to implement
   DATA Copies                 //TO DO  to implement
   DATA Key  PROTECTED         //TO DO  to implement
   DATA Header
   DATA Footer
   DATA BackGround             //TO DO  to implement
   DATA MarginButtom
   DATA MarginLeft
   DATA MarginTop
   DATA MarginRight
   DATA MarginMeasure          //TO DO  to implement
   DATA PaperSize              //TO DO  to implement
   DATA PrintUrl

   DATA lPreview
   DATA lPromptPrint
   DATA lPrintHtml

   DATA PrintDefault INIT Win_PrinterGetDefault() PROTECTED

   METHOD New() CONSTRUCTOR
   METHOD Print()
   METHOD savePrintSetup() PROTECTED
   METHOD restorePrintSetup() PROTECTED
   METHOD changePrintSetup PROTECTED
   METHOD Close()

ENDCLASS

//--------------------------------------------------------------------------------------------//

METHOD New() CLASS HTMLPRINT

   StartObjectWs()
   StartObjectPr()

   ::savePrintSetup()

RETURN Self

//--------------------------------------------------------------------------------------------//
METHOD Print() CLASS HTMLPRINT

   LOCAL lnStarted        && Seconds started for the document
   LOCAL lnWaiting   := 0 && Seconds waiting for the document to load

   DEFAULT ::PrinterName  := ::PrintDefault
   DEFAULT ::Orientation  := 2
   DEFAULT ::Copies       := 1
   DEFAULT ::Footer       := ""
   DEFAULT ::Header       := ""
   DEFAULT ::MarginButtom  := IEMarginBottom
   DEFAULT ::MarginLeft    := IEMarginLeft
   DEFAULT ::MarginTop     := IEMarginTop
   DEFAULT ::MarginRight   := IEMarginRight
   DEFAULT ::MarginMeasure := 1
   DEFAULT ::PaperSize     := 9

   DEFAULT ::lPreview     := .F.
   DEFAULT ::lPromptPrint := .F.
   DEFAULT ::lPrintHtml   := .T.

   lnStarted := SECONDS()

   IF ::PrintUrl != NIL

      // Configura impressora  seta impressora como padrão
      IF ::lPrintHtml
            IF ::PrintDefault # ::PrinterName
               PR:SetDefaultPrinter(::PrinterName)
            ENDIF
      ENDIF

      ::changePrintSetup()

      WB:Visible    := ::lPreview
      WB:Navigate(::PrintUrl)

      WHILE WB:Readystate # READYSTATE_COMPLETE .OR. lnWaiting >= MAX_TIME
         lnWaiting = Seconds() - lnStarted
      ENDDO

      WHILE WB:QueryStatusWB(OLECMDID_PRINT) != (OLECMDF_SUPPORTED + OLECMDF_ENABLED)
      ENDDO

      // Imprime ou Não
      IF ::lPrintHtml
        WB:ExecWB(OLECMDID_PRINT, If(::lPromptPrint, OLECMDEXECOPT_PROMPTUSER, LECMDEXECOPT_DONTPROMPTUSER) )
      ENDIF

   ELSE
      RETURN .F.
   ENDIF

RETURN .T.

//--------------------------------------------------------------------------------------------//
METHOD savePrintSetup() CLASS HTMLPRINT

   // Salva o que está definido como padrão
   IEFooter       := getRegistry( HKEY_CURRENT_USER , IEKey, "footer")
   IEHeader       := getRegistry( HKEY_CURRENT_USER , IEKey, "header")
   IEMarginBottom := getRegistry( HKEY_CURRENT_USER , IEKey, "margin_bottom")
   IEMarginLeft   := getRegistry( HKEY_CURRENT_USER , IEKey , "margin_left")
   IEMarginRight  := getRegistry( HKEY_CURRENT_USER , IEKey , "margin_right")
   IEMarginTop    := getRegistry( HKEY_CURRENT_USER , IEKey, "margin_top")

RETURN NIL

//--------------------------------------------------------------------------------------------//
METHOD changePrintSetup() CLASS HTMLPRINT

   SetRegistry(HKEY_CURRENT_USER , IEKey , "footer",::Footer)
   SetRegistry(HKEY_CURRENT_USER , IEKey , "header",::Header)
   SetRegistry(HKEY_CURRENT_USER , IEKey , "margin_bottom",::MarginButtom)
   SetRegistry(HKEY_CURRENT_USER , IEKey , "margin_left",::MarginLeft)
   SetRegistry(HKEY_CURRENT_USER , IEKey , "margin_right",::MarginRight)
   SetRegistry(HKEY_CURRENT_USER , IEKey , "margin_top",::MarginTop)

RETURN .T.

//--------------------------------------------------------------------------------------------//
METHOD restorePrintSetup() CLASS HTMLPRINT

   IF ( Empty(IEFooter) .Or. IEFooter == NIL )
      IEFooter := "&u&b&d"
   ENDIF

   IF ( Empty(IEHeader) .Or. IEFooter == NIL )
      IEHeader := "&w&bPage &p of &P"
   ENDIF

   SetRegistry(HKEY_CURRENT_USER , IEKey , "footer",IEFooter)
   SetRegistry(HKEY_CURRENT_USER , IEKey , "header",IEHeader)
   SetRegistry(HKEY_CURRENT_USER , IEKey , "margin_bottom",IEMarginBottom)
   SetRegistry(HKEY_CURRENT_USER , IEKey , "margin_left",IEMarginLeft)
   SetRegistry(HKEY_CURRENT_USER , IEKey , "margin_right",IEMarginRight)
   SetRegistry(HKEY_CURRENT_USER , IEKey , "margin_top",IEMarginTop)

RETURN .T.

//--------------------------------------------------------------------------------------------//
METHOD close() CLASS HTMLPRINT

   // Restaura impressora se for o caso.
   PR:SetDefaultPrinter(::PrintDefault)
   ::restorePrintSetup()

   WB := NIL
   PR := NIL
   HP := NIL

RETURN NIL

//--------------------------------------------------------------------------------------------//
STATIC FUNCTION startObjectWS()

   TRY
      WB    := GetActiveObject( "InternetExplorer.Application" )
   CATCH
      TRY
         WB := CreateObject( "InternetExplorer.Application" )
      CATCH
         RETURN Throw(ErrorNew( "HTMLPrint", 0, 0, ProcName(),"ERROR! IExplorer not avialable. [" + Ole2TxtError()+ "]" ))
      END
   END

RETURN .T.

//--------------------------------------------------------------------------------------------//
STATIC FUNCTION startObjectPR()

   TRY
     PR := GetActiveObject("WScript.Network")
   CATCH
     TRY
       PR := CreateObject("WScript.Network")
     CATCH
       RETURN Throw(ErrorNew( "HTMLPrint", 0, 0, ProcName(),"ERROR! Printer network not avialable. [" + Ole2TxtError() + "]"))
     END
   END

RETURN .T.

/*
EOF
*/

/*
&w Window title
&u Page address (URL)
&d Date in short format specified by Regional Settings in Control Panel
&D Date in long format specified by Regional Settings in Control Panel
&t Time in the format specified by Regional Settings in Control Panel
&T Time in 24-hour format
&p Current page number
&P Total number of pages
&& A single ampersand (&)
&b The text immediately following these characters as centered
&b&b The text immediately following the first "&b" as centered, and the text following the second "&b" as right-justified
*/

//---------------------------------------------------------------------------//
/*
FUNCTION TWEB()

   StartObjectWs()

   PUBLICVAR("OIE")

   OIE := getWB()

RETURN OIE
*/
//---------------------------------------------------------------------------//
FUNCTION getHP()
RETURN HP

//---------------------------------------------------------------------------//
FUNCTION getWB
RETURN WB

//--------------------------------------------------------------------------//
FUNCTION HtmlPrintVersion()
RETURN VERSION

M., Ronaldo

by: IMATECH

IMATION TECNOLOGIA
Avatar do usuário
sygecom
Administrador
Administrador
Mensagens: 7131
Registrado em: 21 Jul 2006 10:12
Localização: Alvorada-RS
Contato:

harbour boleto

Mensagem por sygecom »

Eu uso com xHarbour, com algumas alterações que fizemos para ter carteira para o Sicred e outras mais que não deve fazer muita diferença para o que está no CVS.
Leonardo Machado
xHarbour.org + Hwgui + PostgreSql
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

harbour boleto

Mensagem por JoséQuintas »

Acabei achando na internet um jeito de colocar as barras branca e preta dentro do html.
Não sei se pode interessar pro Harbour boleto.
Fica interessante se for mandar o html por email.

<img src=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAABQAQMAAAAa6XZvAAAAA1BMVEUAAACnej3aAAAADElEQVR42mNgGFkAAADwAAE4aVpRAAAAAElFTkSuQmCC width=3 height=50 border=0>
<img src=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAABQAQMAAAAa6XZvAAAAA1BMVEX///+nxBvIAAAADElEQVR42mNgGFkAAADwAAE4aVpRAAAAAElFTkSuQmCC width=3 height=50 border=0>
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Abel
Usuário Nível 3
Usuário Nível 3
Mensagens: 332
Registrado em: 14 Mar 2012 13:16
Localização: sao paulo / sp

harbour boleto

Mensagem por Abel »

valeu imatech,

apos entrar em contato com o BB suporte, me mandaram o manual e eu consegui montar o codigo para carteira 18. (praticamente igual o seu).

estou a uma semana "brincando com os fontes do harbour boleto", ja consigo gerar o boleto em htm, e inclusive ja paguei um boleto teste, so nao consegui receber ainda o retorno do banco. (to resolvendo com o suporte deles ainda).

agora minha dificuldade esta em imprimir sem usar o IE, quando coloco o prg htmlprint da diversos erros de compilacao, sera que é pq eu uso o harbour ? se nao for, quais libs tenho q compilar junto aos fontes. ?

se tiver uma forma de transform o htm em pdf, tambem resolveria. rs

Abracos,
ABEL
Imatech
Usuário Nível 3
Usuário Nível 3
Mensagens: 350
Registrado em: 24 Ago 2010 23:48
Localização: Goiânia-GO

harbour boleto

Mensagem por Imatech »

Olá Abel !


Só vejo vantagens utilizando Harbour ;)
Quem utiliza xH e faça uma simples tentativa de migração ira descobrir o quanto as mensagens do compilador Harbour são úteis na depuração de código...

e

Parabens pela resolução da carteira SR do BB...


Quanto a impressão:

OBOLETO.PRG
Ajustar: METHOD PRINT...

Código: Selecionar todos


METHOD PRINT(lPreview,lPromptPrint,cPrinter) CLASS oBoleto
  DEFAULT lPreview TO ::lPreview
  DEFAULT lPromptPrint TO .T.
  DEFAULT cPrinter TO Win_PrinterGetDefault()

  IF ::lBoleto .AND. ::nBoletos > 0
    IF lPreview
      RM_Shell_Execute_( ::Destino + ::Nomehtm, NIL, NIL )
    ELSE
      RM_Shell_Print_( ::Destino + ::Nomehtm, NIL, NIL )
    ENDIF
  ENDIF
RETURN Self

UTILS_SHELL.C

Código: Selecionar todos

#include "hbapi.h"
#include <windows.h>
#include <shellapi.h>

HB_FUNC( RM_SHELL_EXECUTE_ )
{
   ShellExecute( NULL,
                "OPEN",
                 hb_parc( 1 ),
                 hb_parc( 2 ),
                 hb_parc( 3 ),
                 SW_SHOWMAXIMIZED );
}

HB_FUNC( RM_SHELL_PRINT_ )
{
   ShellExecute( NULL,
                "PRINT",
                 hb_parc( 1 ),
                 hb_parc( 2 ),
                 hb_parc( 3 ),
                 SW_SHOWNORMAL );
}


Opcional: htmlprint.prg para Harbour (Não Testado)

Código: Selecionar todos


/*
 * $Id: htmlprint.prg,v 1.3 2007/06/20 12:29:56 marioargon Exp $
*/
/*
 * xHarbour Project source code:
 * HTMLPRINT engine library class
 *
 * Copyright 2007-2007 Laverson Espíndola <laverson.espindola@gmail.com>
 * www - http://www.xharbour.org http://www.harbour-project.org
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this software; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
 *
 * As a special exception, the Harbour Project gives permission for
 * additional uses of the text contained in its release of Harbour.
 *
 * The exception is that, if you link the Harbour libraries with other
 * files to produce an executable, this does not by itself cause the
 * resulting executable to be covered by the GNU General Public License.
 * Your use of that executable is in no way restricted on account of
 * linking the Harbour library code into it.
 *
 * This exception does not however invalidate any other reasons why
 * the executable file might be covered by the GNU General Public License.
 *
 * This exception applies only to the code released by the Harbour
 * Project under the name Harbour.  If you copy code from other
 * Harbour Project or Free Software Foundation releases into a copy of
 * Harbour, as the General Public License permits, the exception does
 * not apply to the code that you add in this way.  To avoid misleading
 * anyone as to the status of such modified files, you must delete
 * this exception notice from them.
 *
 * If you write modifications of your own for Harbour, it is your choice
 * whether to permit this exception to apply to your modifications.
 * If you do not wish that, delete this exception notice.
 *
 */

#include "hbclass.ch"
#include "common.ch"

#command DEFAULT <param> := <val> [, <paramn> := <valn> ];
=> ;
         <param> := IIF(<param> = NIL, <val>, <param> ) ;
         [; <paramn> := IIF(<paramn> = NIL, <valn>, <paramn> ) ]

#DEFINE OLECMDID_PRINT 6
#DEFINE OLECMDEXECOPT_PROMPTUSER 1
#DEFINE LECMDEXECOPT_DONTPROMPTUSER 2

#DEFINE OLECMDF_SUPPORTED 1
#DEFINE OLECMDF_ENABLED 2

#DEFINE READYSTATE_COMPLETE 4
#DEFINE MAX_TIME 30

#define HKEY_LOCAL_MACHINE  0
#define HKEY_CLASSES_ROOT   1
#define HKEY_CURRENT_USER   2
#define HKEY_CURRENT_CONFIG 3

#ifndef HKEY_LOCAL_MACHINE
#define HKEY_LOCAL_MACHINE  4
#endif

#define HKEY_USERS          5

#define VERSION             "1.0.01"

STATIC IEHeader
STATIC IEFooter
STATIC IEMarginBottom
STATIC IEMarginLeft
STATIC IEMarginRight
STATIC IEMarginTop
STATIC IEKey  := "Software\Microsoft\Internet Explorer\PageSetup"

STATIC WB
STATIC PR

STATIC HP

//--------------------------------------------------------------------------------------------//
FUNCTION PrintHTML(cURL,cPrinter,lPrevIew,lPromptPrint,lPrintHtml,cHeader,cFooter)

   DEFAULT lPrintHtml   := .T.
   DEFAULT lPreview     := .F.
   DEFAULT lPromptPrint := .F.
   DEFAULT cPrinter     := Win_PrinterGetDefault()
   DEFAULT cFooter      := ""
   DEFAULT cHeader      := ""

   IF (HP==NIL)
      HP := HTMLPRINT():NEW()
   ENDIF

   HP:PrintUrl     := cURL
   HP:lPreview     := lPreview
   HP:lPromptPrint := lPromptPrint
   HP:lPrintHtml   := lPrintHtml
   HP:PrinterName  := cPrinter
   HP:Footer       := cFooter
   HP:Header       := cHeader

   HP:Print()
   HP:Close()

RETURN .T.
//--------------------------------------------------------------------------------------------//

CLASS HTMLPRINT

   DATA PrinterName
   DATA Orientation            //TO DO  to implement
   DATA Copies                 //TO DO  to implement
   DATA Key  PROTECTED         //TO DO  to implement
   DATA Header
   DATA Footer
   DATA BackGround             //TO DO  to implement
   DATA MarginButtom
   DATA MarginLeft
   DATA MarginTop
   DATA MarginRight
   DATA MarginMeasure          //TO DO  to implement
   DATA PaperSize              //TO DO  to implement
   DATA PrintUrl

   DATA lPreview
   DATA lPromptPrint
   DATA lPrintHtml

   DATA PrintDefault INIT Win_PrinterGetDefault() PROTECTED

   METHOD New() CONSTRUCTOR
   METHOD Print()
   METHOD savePrintSetup() PROTECTED
   METHOD restorePrintSetup() PROTECTED
   METHOD changePrintSetup PROTECTED
   METHOD Close()

ENDCLASS

//--------------------------------------------------------------------------------------------//

METHOD New() CLASS HTMLPRINT

   StartObjectWs()
   StartObjectPr()

   ::savePrintSetup()

RETURN Self

//--------------------------------------------------------------------------------------------//
METHOD Print() CLASS HTMLPRINT

   LOCAL lnStarted        && Seconds started for the document
   LOCAL lnWaiting   := 0 && Seconds waiting for the document to load

   DEFAULT ::PrinterName  := ::PrintDefault
   DEFAULT ::Orientation  := 2
   DEFAULT ::Copies       := 1
   DEFAULT ::Footer       := ""
   DEFAULT ::Header       := ""
   DEFAULT ::MarginButtom  := IEMarginBottom
   DEFAULT ::MarginLeft    := IEMarginLeft
   DEFAULT ::MarginTop     := IEMarginTop
   DEFAULT ::MarginRight   := IEMarginRight
   DEFAULT ::MarginMeasure := 1
   DEFAULT ::PaperSize     := 9

   DEFAULT ::lPreview     := .F.
   DEFAULT ::lPromptPrint := .F.
   DEFAULT ::lPrintHtml   := .T.

   lnStarted := SECONDS()

   IF ::PrintUrl != NIL

      // Configura impressora  seta impressora como padrão
      IF ::lPrintHtml
            IF ::PrintDefault # ::PrinterName
               PR:SetDefaultPrinter(::PrinterName)
            ENDIF
      ENDIF

      ::changePrintSetup()

      WB:Visible    := ::lPreview
      WB:Navigate(::PrintUrl)

      WHILE WB:Readystate # READYSTATE_COMPLETE .OR. lnWaiting >= MAX_TIME
         lnWaiting = Seconds() - lnStarted
      ENDDO

      WHILE WB:QueryStatusWB(OLECMDID_PRINT) != (OLECMDF_SUPPORTED + OLECMDF_ENABLED)
      ENDDO

      // Imprime ou Não
      IF ::lPrintHtml
        WB:ExecWB(OLECMDID_PRINT, If(::lPromptPrint, OLECMDEXECOPT_PROMPTUSER, LECMDEXECOPT_DONTPROMPTUSER) )
      ENDIF

   ELSE
      RETURN .F.
   ENDIF

RETURN .T.

//--------------------------------------------------------------------------------------------//
METHOD savePrintSetup() CLASS HTMLPRINT

   // Salva o que está definido como padrão
   IEFooter       := getRegistry( HKEY_CURRENT_USER , IEKey, "footer")
   IEHeader       := getRegistry( HKEY_CURRENT_USER , IEKey, "header")
   IEMarginBottom := getRegistry( HKEY_CURRENT_USER , IEKey, "margin_bottom")
   IEMarginLeft   := getRegistry( HKEY_CURRENT_USER , IEKey , "margin_left")
   IEMarginRight  := getRegistry( HKEY_CURRENT_USER , IEKey , "margin_right")
   IEMarginTop    := getRegistry( HKEY_CURRENT_USER , IEKey, "margin_top")

RETURN NIL

//--------------------------------------------------------------------------------------------//
METHOD changePrintSetup() CLASS HTMLPRINT

   SetRegistry(HKEY_CURRENT_USER , IEKey , "footer",::Footer)
   SetRegistry(HKEY_CURRENT_USER , IEKey , "header",::Header)
   SetRegistry(HKEY_CURRENT_USER , IEKey , "margin_bottom",::MarginButtom)
   SetRegistry(HKEY_CURRENT_USER , IEKey , "margin_left",::MarginLeft)
   SetRegistry(HKEY_CURRENT_USER , IEKey , "margin_right",::MarginRight)
   SetRegistry(HKEY_CURRENT_USER , IEKey , "margin_top",::MarginTop)

RETURN .T.

//--------------------------------------------------------------------------------------------//
METHOD restorePrintSetup() CLASS HTMLPRINT

   IF ( Empty(IEFooter) .Or. IEFooter == NIL )
      IEFooter := "&u&b&d"
   ENDIF

   IF ( Empty(IEHeader) .Or. IEFooter == NIL )
      IEHeader := "&w&bPage &p of &P"
   ENDIF

   SetRegistry(HKEY_CURRENT_USER , IEKey , "footer",IEFooter)
   SetRegistry(HKEY_CURRENT_USER , IEKey , "header",IEHeader)
   SetRegistry(HKEY_CURRENT_USER , IEKey , "margin_bottom",IEMarginBottom)
   SetRegistry(HKEY_CURRENT_USER , IEKey , "margin_left",IEMarginLeft)
   SetRegistry(HKEY_CURRENT_USER , IEKey , "margin_right",IEMarginRight)
   SetRegistry(HKEY_CURRENT_USER , IEKey , "margin_top",IEMarginTop)

RETURN .T.

//--------------------------------------------------------------------------------------------//
METHOD close() CLASS HTMLPRINT

   // Restaura impressora se for o caso.
   PR:SetDefaultPrinter(::PrintDefault)
   ::restorePrintSetup()

   WB := NIL
   PR := NIL
   HP := NIL

RETURN NIL

//--------------------------------------------------------------------------------------------//
STATIC FUNCTION startObjectWS()

   TRY
      WB    := GetActiveObject( "InternetExplorer.Application" )
   CATCH
      TRY
         WB := CreateObject( "InternetExplorer.Application" )
      CATCH
         RETURN Throw(ErrorNew( "HTMLPrint", 0, 0, ProcName(),"ERROR! IExplorer not avialable. [" + Ole2TxtError()+ "]" ))
      END
   END

RETURN .T.

//--------------------------------------------------------------------------------------------//
STATIC FUNCTION startObjectPR()

   TRY
     PR := GetActiveObject("WScript.Network")
   CATCH
     TRY
       PR := CreateObject("WScript.Network")
     CATCH
       RETURN Throw(ErrorNew( "HTMLPrint", 0, 0, ProcName(),"ERROR! Printer network not avialable. [" + Ole2TxtError() + "]"))
     END
   END

RETURN .T.

/*
EOF
*/

/*
&w Window title
&u Page address (URL)
&d Date in short format specified by Regional Settings in Control Panel
&D Date in long format specified by Regional Settings in Control Panel
&t Time in the format specified by Regional Settings in Control Panel
&T Time in 24-hour format
&p Current page number
&P Total number of pages
&& A single ampersand (&)
&b The text immediately following these characters as centered
&b&b The text immediately following the first "&b" as centered, and the text following the second "&b" as right-justified
*/

//---------------------------------------------------------------------------//
/*
FUNCTION TWEB()

   StartObjectWs()

   PUBLICVAR("OIE")

   OIE := getWB()

RETURN OIE
*/
//---------------------------------------------------------------------------//
FUNCTION getHP()
RETURN HP

//---------------------------------------------------------------------------//
FUNCTION getWB
RETURN WB

//--------------------------------------------------------------------------//
FUNCTION HtmlPrintVersion()
RETURN VERSION

M., Ronaldo

by: IMATECH

IMATION TECNOLOGIA
Abel
Usuário Nível 3
Usuário Nível 3
Mensagens: 332
Registrado em: 14 Mar 2012 13:16
Localização: sao paulo / sp

harbour boleto

Mensagem por Abel »

voltei,

consegui fazer a impressao pelo fonte original (opcao q vc escreveu nao testado), adicionando na compilacao os comandos abaixo:

-lxhb
-lhbwin

fiz alguns ajustes nas opcoes lprint, lpromptprint, e lpreview e esta imprimindo.

so tem uma coisa, a ultima linha que ele imprime sai o caminho do meu arquivo htm

exemplo:
"file://c:\sistema\boleto\boleto.htm ", seria possivel retirar esta linha e a data que sai do canto direito embaixo ?

Abracos, e valeu pela força.
ABEL
Avatar do usuário
ANDRIL
Usuário Nível 5
Usuário Nível 5
Mensagens: 1298
Registrado em: 06 Jul 2004 00:44
Contato:

harbour boleto

Mensagem por ANDRIL »

Abel escreveu:"file://c:\sistema\boleto\boleto.htm ", seria possivel retirar esta linha e a data que sai do canto direito embaixo ?
Estes dados me parece ser do rodapé do IE. Verifique em configuração de página se consegue desativa-lo. Não sei se tem como faze-lo automatico.

Nos testes que fiz, não sei se é por que uso o Google Chrome como navegador padrão, não consigo imprimir direto. Alguém passou por esta dificuldade?

Seria difícil converter um HTML em PDF, tem alguma classe ou função para isto no [x]harbour? Assim acabaria de vez com o problema de diferença entre os browsers.

Ate+
Clipper 5.2e / Blinker 5.1 / Harbour 3.2 / GTwvg
lucimauro
Usuário Nível 3
Usuário Nível 3
Mensagens: 465
Registrado em: 21 Set 2004 21:02
Localização: Sobral-CE

harbour boleto

Mensagem por lucimauro »

Abel;

voce compilou com harbour, qual versão?

e tambem voce compilou a UTILS_SHELL.C

Porque aqui quando eu compilo ela da um erro. num arquivo .H
Imatech
Usuário Nível 3
Usuário Nível 3
Mensagens: 350
Registrado em: 24 Ago 2010 23:48
Localização: Goiânia-GO

harbour boleto

Mensagem por Imatech »

Olá Lucimauro !



As adaptações disponibilizadas foram testadas com Harbour 3.xx + Compiladores MSVC e MingW



Que arquivo .h falta em sua compilação (e que ambiente usa para compilação) ?




Abç...
M., Ronaldo

by: IMATECH

IMATION TECNOLOGIA
lucimauro
Usuário Nível 3
Usuário Nível 3
Mensagens: 465
Registrado em: 21 Set 2004 21:02
Localização: Sobral-CE

harbour boleto

Mensagem por lucimauro »

Este é o erro que da na minha compilação
Harbour 3.0
Mingw

C:\fontes\SISTEMA\novo>HBMK2 SCE.hbp /N /M /B
hbmk2: Harbour: Compilando módulos...
Harbour 3.0.0 (Rev. 16951)
Copyright (c) 1999-2011, http://harbour-project.org/
Compiling 'oboleto.prg'...
C:\hb30\include\hbdefs.h(56) Error F0029 Can't open #include file 'stdarg.h'
hbmk2: Erro: Executando o compilador Harbour (interno): 1
(C:\hb30\bin\harbour.exe) -n2 oboleto.prg /N /M /B -o.hbmk\win\mingw\ -iC:\hb30\include


Se alguem puder me ajudar agradeço.
Responder