Formatacao errada com o win32prn
Enviado: 26 Mar 2008 15:11
Caros, pq quando imprimo qualquer relatorio em impressoras matriciais a paginacao sai errada, ou seja, comeca certo jah na segunda pagina em diante (no salto da pagina) ele inicia mais em baixo e isso vai acumulando no relatorio ficando as paginas seguintes fora de padrao. Quando imprimo em impressora jato/laser sai normal. Segue abaixo o codigo:
Código: Selecionar todos
function confimpr()
#define FORM_A4 9
#define PS_SOLID 0
#define RGB( nR,nG,nB ) ( nR + ( nG * 256 ) + ( nB * 256 * 256 ) )
#define BLACK RGB( 0x0 ,0x0 ,0x0 )
#define BLUE RGB( 0x0 ,0x0 ,0x85 )
#define GREEN RGB( 0x0 ,0x85,0x0 )
#define CYAN RGB( 0x0 ,0x85,0x85 )
#define RED RGB( 0x85,0x0 ,0x0 )
#define MAGENTA RGB( 0x85,0x0 ,0x85 )
#define BROWN RGB( 0x85,0x85,0x0 )
#define WHITE RGB( 0xC6,0xC6,0xC6 )
LOCAL nPrn:=1, cBMPFile:= SPACE( 40 )
LOCAL oItems:=aPrn:= GetPrinters()
Local oModDlg, oFont := HFont():Add( "MS Sans Serif",0,-13 )
Local oList
vmens1:=vmens2:=vmens3:=""
INIT DIALOG oModDlg CLIPPER NOEXIT TITLE "Escolha a impressora" ;
AT 0,0 SIZE 550,350 ;
FONT oFont
@ 20,20 GET COMBOBOX oList ITEMS oItems SIZE 500, 250
// @ 10,40 LISTBOX oList ITEMS oItems ;
// OF oModDlg ;
// INIT 1 ;
// SIZE 510, 220 ;
// TOOLTIP "Escolha a impressora"
@ 10,280 BUTTON "Ok" SIZE 50, 32 ON CLICK {||oModDlg:lResult:=.T.,EndDialog()} STYLE WS_TABSTOP + BS_DEFPUSHBUTTON
ACTIVATE DIALOG oModDlg
oFont:Release()
nPrn:=oList
IF oModDlg:lResult
IF EMPTY(aPrn)
atenc(19,10,"Nao existe impressora instalada.")
return .f.
ENDIF
DO WHILE !EMPTY(nPrn)
cBMPfile:=""
IF !EMPTY(nPrn)
PrnTest(aPrn[nPrn], cBMPFile)
ENDIF
exit
enddo
ENDIF
Return Nil
FUNCTION PrnTest(cPrinter, cBMPFile)
local arqimp:=alltrim(netname())+STRZERO(SECONDS(),5,0)
oPrinter:= Win32Prn():New(cPrinter)
oPrinter:Landscape:= .F.
oPrinter:FormType := FORM_A4
oPrinter:Copies := 1
IF !oPrinter:Create()
atenc(19,10,"Nao foi possivel imprimir.")
ELSE
IF !oPrinter:startDoc((arqimp))
atenc(19,10,"Nao foi possivel iniciar a impressao.")
endif
endif
cabecalho(oPrinter)
return .t.
function cabecalho(oPrinter)
oPrinter:NewLine()
oPrinter:NewLine()
oPrinter:Bold(800) // NEGRITO
oPrinter:SetFont('Courier New',18,0)
oPrinter:TextOUT(padc(transform(alltrim(EMPRESA->FANTASIA),"@!"),60))
oPrinter:Bold(0) // Normal
oPrinter:SetFont('Courier New',14,0)
oPrinter:NewLine()
oPrinter:TextOut(padc(transform(alltrim(EMPRESA->ENDERECO),"@S24")+" - "+transform(alltrim(EMPRESA->CIDADE),"@S10")+" - "+transform(alltrim(EMPRESA->BAIRRO),"@S10"),70))
oPrinter:NewLine()
oPrinter:TextOut(padc(transform(EMPRESA->TELEFONE,"(99999) 9999-9999"),70))
oPrinter:NewLine()
oPrinter:TextOut(padc(ALLTRIM("CNPJ:"+EMPRESA->CGC)+" I.E."+ALLTRIM(EMPRESA->INSCRICAO),70))
oPrinter:NewLine()
****oPrinter:Line(0, oPrinter:PosY+5, 2000, oPrinter:PosY+5)
oPrinter:NewLine()
*oPrinter:SetFont('Courier New',12,0)
return .t.