Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Imprimir Tiickets en VB.NET

346 views
Skip to first unread message

Juan Gerardo Cardenas Trigueros

unread,
Aug 1, 2006, 6:02:59 PM8/1/06
to
Alguien me podria decir como o en donde puedo encontrar información para
imprimir reportes de tipo ticket con una miniprinter. Gracias.

Fernando

unread,
Aug 2, 2006, 3:00:43 AM8/2/06
to
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

Roberto

unread,
Aug 8, 2006, 6:48:01 AM8/8/06
to
En vb2005 avisa de que esta API está obsoleta y recomienda usar un
SafeFileHandle, aunque así funcionaría. Lo he probado pero hace unas pausas
muy grandes al cabo de unas pocas líneas.

He añadido el SafeFileHandle y funciona bien, y si fuera necesario nos
permite cambiar el tamaño del buffer.



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

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim Safe As New Microsoft.Win32.SafeHandles.SafeFileHandle(hPortP,
True)
outFile = New System.IO.FileStream(Safe, IO.FileAccess.Write) 'Aquí
podemos cambiar el tamaño del buffer.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


Dim fileWriter As New StreamWriter(outFile)
fileWriter.WriteLine(Chr(27) & Chr(112) & 0) 'abrir cajón
fileWriter.WriteLine(" " & " Empresa")
fileWriter.WriteLine(" " & " se dedica a ")

.....

alfredoi...@gmail.com

unread,
Nov 30, 2014, 4:05:45 PM11/30/14
to
El martes, 1 de agosto de 2006 18:02:59 UTC-4, 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.

HOLAAMIGOCONTACTAME

narcisom...@gmail.com

unread,
Apr 9, 2016, 5:03:05 PM4/9/16
to
El martes, 1 de agosto de 2006, 16:02:59 (UTC-6), 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.

Y por que no usan Crystal Reports?
0 new messages