No meu sistema preciso utilizar impressora generica somente texto, até ai imprimo td ok.
Só que quando tento acionar a guilhotina da impressora não funciona, simplesmente a impressão acaba e não faz o corte.
Segue o meu codigo :
Public Declare Function OpenPrinter Lib "winspool.drv" _
Alias "OpenPrinterA" (ByVal pPrinterName As String, _
phPrinter As Long, ByVal pDefault As Long) As Long
Public Declare Function StartDocPrinter Lib "winspool.drv" _
Alias "StartDocPrinterA" (ByVal hPrinter As Long, _
ByVal Level As Long, pDocInfo As DOCINFO) As Long
Public Declare Function StartPagePrinter Lib "winspool.drv" _
(ByVal hPrinter As Long) As Long
Public Declare Function WritePrinter Lib "winspool.drv" _
(ByVal hPrinter As Long, pBuf As Any, _
ByVal cdBuf As Long, pcWritten As Long) As Long
Public Declare Function ClosePrinter Lib "winspool.drv" _
(ByVal hPrinter As Long) As Long
Public Declare Function EndDocPrinter Lib "winspool.drv" _
(ByVal hPrinter As Long) As Long
Public Declare Function EndPagePrinter Lib "winspool.drv" _
(ByVal hPrinter As Long) As Long
Public Type DOCINFO
pDocName As String
pOutputFile As String
pDatatype As String
End Type
Dim printerHandle As Long, retVal As Long
Dim bytesWritten As Long, lDoc As Long
Dim s1 As String, MyDocInfo As DOCINFO
retVal = OpenPrinter(Printer.DeviceName, printerHandle, 0)
If retVal = 0 Then
MsgBox "Printer Not found"
Exit Sub
End If
Pergunta
Raul_macedo
Estou com o seguinte problema.
No meu sistema preciso utilizar impressora generica somente texto, até ai imprimo td ok.
Só que quando tento acionar a guilhotina da impressora não funciona, simplesmente a impressão acaba e não faz o corte.
Segue o meu codigo :
Public Declare Function OpenPrinter Lib "winspool.drv" _
Alias "OpenPrinterA" (ByVal pPrinterName As String, _
phPrinter As Long, ByVal pDefault As Long) As Long
Public Declare Function StartDocPrinter Lib "winspool.drv" _
Alias "StartDocPrinterA" (ByVal hPrinter As Long, _
ByVal Level As Long, pDocInfo As DOCINFO) As Long
Public Declare Function StartPagePrinter Lib "winspool.drv" _
(ByVal hPrinter As Long) As Long
Public Declare Function WritePrinter Lib "winspool.drv" _
(ByVal hPrinter As Long, pBuf As Any, _
ByVal cdBuf As Long, pcWritten As Long) As Long
Public Declare Function ClosePrinter Lib "winspool.drv" _
(ByVal hPrinter As Long) As Long
Public Declare Function EndDocPrinter Lib "winspool.drv" _
(ByVal hPrinter As Long) As Long
Public Declare Function EndPagePrinter Lib "winspool.drv" _
(ByVal hPrinter As Long) As Long
Public Type DOCINFO
pDocName As String
pOutputFile As String
pDatatype As String
End Type
Dim printerHandle As Long, retVal As Long
Dim bytesWritten As Long, lDoc As Long
Dim s1 As String, MyDocInfo As DOCINFO
retVal = OpenPrinter(Printer.DeviceName, printerHandle, 0)
If retVal = 0 Then
MsgBox "Printer Not found"
Exit Sub
End If
MyDocInfo.pDocName = "Any Name"
MyDocInfo.pOutputFile = vbNullString
MyDocInfo.pDatatype = vbNullString
lDoc = StartDocPrinter(printerHandle, 1, MyDocInfo)
Call StartPagePrinter(printerHandle)
s1 = mvImpressaoTexto
retVal = WritePrinter(printerHandle, ByVal s1, _
Len(s1), bytesWritten)
retVal = EndPagePrinter(printerHandle)
retVal = EndDocPrinter(printerHandle)
retVal = ClosePrinter(printerHandle)
alguém por favor poderia me ajudar a fazer acionar a guilhotina da impressora.
Link para o comentário
Compartilhar em outros sites
4 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.