Página 2 de 3
como imprimir relatorio feito em html
Enviado: 29 Jan 2016 17:51
por asimoes
Porter,
Uma alteração:
Código: Selecionar todos
cArq := "rundll32.exe mshtml.dll,PrintHTML " + '"C:\NFCE\CUPOM.HTML"'
como imprimir relatorio feito em html
Enviado: 29 Jan 2016 18:03
por porter
asimoes, agora deu certo, muito obrigado, esta abrindo a tela para confirmar impressora e clicar no botao Imprimir, tem como imprimir sem passar por essa tela ?
obrigado.
como imprimir relatorio feito em html
Enviado: 29 Jan 2016 18:23
por asimoes
Porter,
Outra dica legal.
Para não mostrar a tela preta quando executa ! (cArq)
cArq := "rundll32.exe mshtml.dll,PrintHTML " + '"C:\NFCE\CUPOM.HTML"'
Execute(cArq)
Código: Selecionar todos
FUNCTION Execute(cProgram, lEspera)
LOCAL oShell, lOk := .T., nStyle
hb_Default(@lEspera,.T.)
TRY
oShell:=WIN_OleCreateObject( "WScript.Shell" )
CATCH
TRY
oShell:=WIN_OleCreateObject( "WScript.Shell" )
CATCH
lOk := .F.
END
END
IF lOk
TRY
/*
intWindowStyle
Description
0 Hides the window and activates another window.
1 Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
2 Activates the window and displays it as a minimized window.
3 Activates the window and displays it as a maximized window.
4 Displays a window in its most recent size and position. The active window remains active.
5 Activates the window and displays it in its current size and position.
6 Minimizes the specified window and activates the next top-level window in the Z order.
7 Displays the window as a minimized window. The active window remains active.
8 Displays the window in its current state. The active window remains active.
9 Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
10 Sets the show-state based on the state of the program that started the application.
*/
nStyle:=0
oShell:Run("%comspec% /c "+cProgram , nStyle, lEspera)
CATCH
Alert("Erro executando "+cProgram, "Erro")
lOk := .F.
END
oShell:=Nil
ENDIF
RETURN lOk
como imprimir relatorio feito em html
Enviado: 29 Jan 2016 19:05
por porter
nas duas linhas marcadas, da erro: Unresolved external, tenho que declarar alguma lib ?
03 hb_Default(@lEspera,.T.)
04 TRY
05 oShell:=WIN_OleCreateObject( "WScript.Shell" ) <-- erro de compilacao nessa linha
06 CATCH
07 TRY
08 oShell:=WIN_OleCreateObject( "WScript.Shell" ) <-- erro de compilacao nessa linha
09 CATCH
10 lOk := .F.
11 END
12 END
como imprimir relatorio feito em html
Enviado: 29 Jan 2016 20:39
por asimoes
Você está compilando com que versão do harbour?
como imprimir relatorio feito em html
Enviado: 29 Jan 2016 22:33
por asimoes
Dá pra simular um enter na janela de Imprimir:
Estou usando a hwgui para este teste:
Código: Selecionar todos
cProg:="rundll32.exe mshtml.dll,PrintHTML"
cPar1:="D:\Harbour\h-Banner\rotinas.html"
cPar2:=win_PrinterGetDefault()
*------------------------------------------------------------------
Executa a função execute como thread
hb_threadStart(@Execute(),cProg,cPar1,cPar2)
*------------------------------------------------------------------
* Procura a janela de diálogo de impressão do internet explorer
nJanela:=hwg_FindWindow(,"Imprimir")
*------------------------------------------------------------------
* Volta pra janela do sistema
wvg_SetForegroundWindow(hb_gtInfo( HB_GTI_WINHANDLE ))
hwg_SendMessage( hb_gtInfo( HB_GTI_WINHANDLE ),WM_SYSCOMMAND,SC_RESTORE,0)
*------------------------------------------------------------------
* Aguarda 1 segundo, é importante para funcionar o comando abaixo.
Inkey(1)
*------------------------------------------------------------------
*simula o enter na janela Imprimir
hwg_KEYB_EVENT( VK_RETURN )
*------------------------------------------------------------------
como imprimir relatorio feito em html
Enviado: 29 Jan 2016 23:46
por asimoes
Simplificando mais:
hb_threadStart(@Execute(),cProg,cPar1,cPar2)
Inkey(1)
hwg_KEYB_EVENT( VK_RETURN )
como imprimir relatorio feito em html
Enviado: 30 Jan 2016 08:30
por porter
bom dia,
asimoes, estou compilando com o xHarbour.
xHarbour Compiler build 1.2.1 (Simplex) (Rev. 6633)
obrigado.
como imprimir relatorio feito em html
Enviado: 30 Jan 2016 09:50
por asimoes
Porter,
As soluções que eu apresentei não funcionam no xharbour.
Essa aqui iria simular um enter na janela Imprimir, o problema é que em xharbour até onde eu sei, thread não funciona 100%, a função hwg_KEYB_EVENT é da hwgui, mas pode pegar o código em c e usar no fonte, não seria problema.
hb_threadStart(@Execute(),cProg,cPar1,cPar2)
Inkey(1)
hwg_KEYB_EVENT( VK_RETURN )
como imprimir relatorio feito em html
Enviado: 30 Jan 2016 09:55
por asimoes
Outras soluções que existem são pagas, não sei de uma free, teria que pesquisar na net.
como imprimir relatorio feito em html
Enviado: 30 Jan 2016 10:18
por porter
assimoes,
As dicas e ejuda que você passou, ja me ajudou muito, mais uma vez sou muito grato por sua atenção.
muito obrigado.
como imprimir relatorio feito em html
Enviado: 30 Jan 2016 10:38
por asimoes
Porter,
Você pode converter o html para pdf e usar o sumatrapdf para imprimir.
como imprimir relatorio feito em html
Enviado: 30 Jan 2016 10:56
por porter
Você pode converter o html para pdf e usar o sumatrapdf para imprimir.
Mas essa conversão daria para o proprio sistema fazer ?
Eu preciso imprimir o Cupom Fiscal Eletronico - SAT e o usuario nao vai querer fazer essa conversão.
como imprimir relatorio feito em html
Enviado: 30 Jan 2016 11:07
por asimoes
Porter,
Achei um coversor free de html para pdf. (anexo)
Sintaxe:
wkhtmltopdf.exe seuhtml.html seuhtml.pdf
Link:
http://download.gna.org/wkhtmltopdf/0.1 ... -win32.exe
Na instalação escolhe uma outra pasta que não seja do windows, o que interessa está na pasta bin.
Já fiz um teste aqui, funciona.
Depois de convertido o html para pdf tem várias soluções para impressão, uma opção free é o sumatrapdf, tem exemplos aqui no fórum
como imprimir relatorio feito em html
Enviado: 30 Jan 2016 11:12
por porter
beleza, vou testar e retorno o resultado.