Imprimir Tiickets en VB.NET

02/08/2006 - 00:02 por Juan Gerardo Cardenas Trigueros | Informe spam
Alguien me podria decir como o en donde puedo encontrar información para
imprimir reportes de tipo ticket con una miniprinter. Gracias.
 

Leer las respuestas

#1 Fernando
02/08/2006 - 09:00 | Informe spam
Juan Gerardo Cardenas Trigueros escribió:
Alguien me podria decir como o en donde puedo encontrar información para
imprimir reportes de tipo ticket con una miniprinter. Gracias.





Hola , te envío esto a ver si te sirve :

Primero declaras esto:

Public Const GENERIC_WRITE = &H40000000
Public Const OPEN_EXISTING = 3
Public Const FILE_SHARE_WRITE = &H2
Public LPTPORT As String
Public hPort As Integer, hPortP As IntPtr
Public retval As Integer
Public Declare Function CreateFile Lib "kernel32" Alias
"CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As
Integer, _
ByVal dwShareMode As Integer, ByRef lpSecurityAttributes As
SECURITY_ATTRIBUTES, ByVal dwCreationDisposition As Integer, _
ByVal dwFlagsAndAttributes As Integer, ByVal hTemplateFile As
Integer) As Integer
Public Declare Function CloseHandle Lib "kernel32" Alias
"CloseHandle" (ByVal hObject As Integer) _
As Integer
Public Structure SECURITY_ATTRIBUTES
Private nLength As Integer
Private lpSecurityDescriptor As Integer
Private bInheritHandle As Integer
End Structure

luego haces esto :

Dim SA As SECURITY_ATTRIBUTES
Dim outFile As FileStream
LPTPORT = "LPT1"
hPort = CreateFile(LPTPORT, GENERIC_WRITE, FILE_SHARE_WRITE,
SA, OPEN_EXISTING, 0, 0)
hPortP = New IntPtr(hPort) 'convert Integer to IntPtr
outFile = New FileStream(hPortP, FileAccess.Write, False)
Dim fileWriter As New StreamWriter(outFile)
fileWriter.WriteLine(Chr(27) & Chr(112) & 0) 'abrir cajón
fileWriter.WriteLine(" " & " Empresa")
fileWriter.WriteLine(" " & " se dedica a ")
fileWriter.WriteLine(" " & " CIF :111111111")
fileWriter.WriteLine(" " & " Fecha : " & Today)
fileWriter.WriteLine(" " &
"")
fileWriter.WriteLine(" " & "Articulo " & " Precio " & "
Cantidad " & " Total ")
fileWriter.WriteLine(" " &
"")

Es para imprimir tickets directamente a travez de impresoras con caja
registradora.
Espero que te sirva, a mi me sirvió.Saludos

Fernando

Preguntas similares