Für Hilfe wäre ich sehr dankbar
Gruss
Stefan
"Stefan Maier" <stefa...@gmx.de> schrieb:
========
Evtl. mag es daran liegen, das dein "Kassendrucker" schneller ist wenn er
Plain Text druckt und langsamer als GDI-Drucker fungiert.
Vielleicht läßt sich ja das beigefügte Beispiel "schnell" drucken.
Gruß
Volker
Beispiel entnommen von:
http://de.gotdotnet.com/quickstart/aspplus/default.aspx?url=%2fquickstart%2fwinforms%2fdoc%2fWinFormsPrinting.aspx
Schritt 3.
Private Sub printButton_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Try
Dim streamToPrint As StreamReader = New StreamReader("PrintMe.Txt")
Try
'Assumes the default printer
Dim pd As TextFilePrintDocument = New
TextFilePrintDocument(streamToPrint)
Dim dlg As New PrintDialog()
dlg.Document = pd
Dim result As DialogResult = dlg.ShowDialog()
If (result = System.Windows.Forms.DialogResult.OK) Then
pd.Print()
End If
Finally
streamToPrint.Close()
End Try
Catch ex As Exception
MessageBox.Show("An error occurred printing the file - " +
ex.Message)
End Try
End Sub
Habe aber den Fehler gefunden, denn ich muss interne
fonts benutzen. Habe nur das Problem, dass ich Sie nicht
ansprechen kann. In Word z.B. kann ich Sie auswählen, Sie
haben alle ein "Druckersymbol" anstatt "TT" für TrueType.
Wenn ich Sie jetzt aber verusuche anzusprechen nimmt
Windows diese nicht :-(.
Kann mir wer helfen, wie ich diese ansprechen kann !!!!
Hier mein kl. Listing:
Private Sub PrintDocument1_PrintPage(ByVal sender As
Object, ByVal ev As PrintPageEventArgs) Handles
PrintDocument1.PrintPage
ev.Graphics.DrawString("TESTDRUCK", New Font
("FontA11", 11, FontStyle.Regular), Brushes.Black, 0, 0)
End Sub
Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
PrintDocument1.Print()
End Sub
> haben alle ein "Druckersymbol" anstatt "TT" für TrueType.
> Wenn ich Sie jetzt aber verusuche anzusprechen nimmt
> Windows diese nicht :-(.
> Kann mir wer helfen, wie ich diese ansprechen kann !!!!
soweit ich weiss kann .NET (wegen Windows-GDI+) nur TrueType Fonts.
Falls Plain-Text genügt (+ evtl. Printer-Codes zum Schrift umschalten)
http://support.microsoft.com/?kbid=322090
--
Thomas Scheidegger - MVP .NET - 'NETMaster'
http://www.cetus-links.org/oo_dotnet.html - http://dnetmaster.net/
Aber wie kann ich dann das Euro Zeichen drucken.
Weiss sonst noch einer Rat
Gruss
Stefan
Schöne Grüße
Daniel
"Stefan" <anon...@discussions.microsoft.com> schrieb im Newsbeitrag
news:676401c47576$1456a570$a401...@phx.gbl...
Wie gesagt, nur falls Plain-Text genügt:
(dafür maximalen Speed)
Wobei man mit Epson ESC-Sequenzen oft auch recht viel
ereichen kann (zB Schriftgrösse usw).
Vielleicht:
http://www.epson.de/rsd/german/about/euroinfo/
also
- ggf. erst eine aktuelle Firmware laden
- richtige Printer-Einstellungen (DIP-Schalter, SW-Config)
- Per VB.NET korrekte ESC-Sequenzen an Printer senden.
(Programmier-Handbuch zum Epson!)
- Code des Euro-Symbol auf Epson-Printer finden:
(vermutlich auf neuer Epson-Codepage PC858 : D5 hex )
http://www.microsoft.com/globaldev/reference/oem/858.htm
(oder falls vorhanden: ISO 8859-15 & A4 hex)
http://www.microsoft.com/globaldev/reference/iso/28605.htm
Leider ist
http://support.microsoft.com/?kbid=322090
Methode 'SendStringToPrinter'
auf Ansi-Codepage fix codiert (+ alles unnötig kompliziert!) ...
Hier deshalb eine geänderte Version [kaum getestet!]
Der Sample-Code nutzt auch .NET-Encoding, somit kann man mit
.NET -Strings & Unicode (Euro : 20AC hex) arbeiten.
Wobei ggf. im Windows control-panel
die Codepage (858) erst installiert werden muss.
'------------------------------ at your own risk --------------------------------------
Imports System.IO
Imports System.Runtime.InteropServices
Imports System.Text
..........
' SAMPLE CODE:
Dim printerName As String = "Epson ?xxxxxxxxxxxxxxxx?"
'TODO: add any needed epson escape sequences to txt :
Dim txt As String = "Text with Euro symbol: " + ChrW(&H20AC) + Environment.NewLine
Dim cp As Encoding = Encoding.GetEncoding(28605) ' ISO 8859-15 Latin 9 & Euro
' Dim cp As Encoding = Encoding.GetEncoding(858) ' 858 (must be installed in windows control panel)
Dim datas As Byte() = cp.GetBytes(txt)
RawPrinterHelperEx.SendBytesToPrinter(printerName, datas)
...............
Public Class RawPrinterHelperEx
' Structure and API declarions:
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> _
Structure DocInfo2
<MarshalAs(UnmanagedType.LPTStr)> Public DocName As String
<MarshalAs(UnmanagedType.LPTStr)> Public OutputFile As String
<MarshalAs(UnmanagedType.LPTStr)> Public DataType As String
Public Mode As Int32 ' Win9x only
Public JobId As Int32 ' Win9x only
End Structure
<DllImport("winspool.drv", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function OpenPrinter(ByVal name As String, ByRef handle As IntPtr, ByVal pd As IntPtr) As Boolean
End Function
<DllImport("winspool.drv", SetLastError:=True, ExactSpelling:=True)> _
Private Shared Function ClosePrinter(ByVal handle As IntPtr) As Boolean
End Function
<DllImport("winspool.drv", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function StartDocPrinter(ByVal handle As IntPtr, ByVal level As Int32, _
ByRef info As DocInfo2) As Boolean
End Function
<DllImport("winspool.drv", SetLastError:=True, ExactSpelling:=True)> _
Private Shared Function EndDocPrinter(ByVal handle As IntPtr) As Boolean
End Function
<DllImport("winspool.drv", SetLastError:=True, ExactSpelling:=True)> _
Private Shared Function StartPagePrinter(ByVal handle As IntPtr) As Boolean
End Function
<DllImport("winspool.drv", SetLastError:=True, ExactSpelling:=True)> _
Private Shared Function EndPagePrinter(ByVal handle As IntPtr) As Boolean
End Function
<DllImport("winspool.drv", SetLastError:=True, ExactSpelling:=True)> _
Private Shared Function WritePrinter(ByVal handle As IntPtr, ByVal datas As Byte(), _
ByVal count As Int32, ByRef written As Int32) As Boolean
End Function
' SendBytesToPrinter()
' When the function is given a printer name and an byte-array,
' the function sends those bytes to the print queue.
' Returns True on success or False on failure.
Public Shared Function SendBytesToPrinter(ByVal printerName As String, ByVal datas As Byte()) As Boolean
Dim handle As IntPtr ' The printer handle.
Dim err As Int32 ' Last error - in case there was trouble.
Dim info As DocInfo2 ' Describes your document (name, port, data type).
Dim written As Int32 ' The number of bytes written by WritePrinter().
Dim ok As Boolean ' Your success code.
With info ' Set up the DOCINFO structure.
.DocName = "My Visual Basic .NET RAW Document"
.DataType = "RAW"
End With
ok = False ' Assume failure unless you specifically succeed.
If OpenPrinter(printerName, handle, IntPtr.Zero) Then
If StartDocPrinter(handle, 1, info) Then
If StartPagePrinter(handle) Then
ok = WritePrinter(handle, datas, datas.Length, written)
EndPagePrinter(handle)
End If
EndDocPrinter(handle)
End If
ClosePrinter(handle)
End If
' If you did not succeed, GetLastError may give more information about why not.
If ok = False Then
err = Marshal.GetLastWin32Error()
End If
Return ok
End Function ' SendBytesToPrinter()
' SendFileToPrinter()
' When the function is given a file name and a printer name,
' the function reads the contents of the file and sends the
' contents to the printer.
' Presumes that the file contains printer-ready data.
' Shows how to use the SendBytesToPrinter function.
' Returns True on success or False on failure.
Public Shared Function SendFileToPrinter(ByVal printerName As String, ByVal fileName As String) As Boolean
Dim fs As New FileStream(fileName, FileMode.Open, FileAccess.Read)
Dim datas(fs.Length) As Byte
fs.Read(datas, 0, fs.Length) ' Read the file.
fs.Close()
Dim ok As Boolean
ok = SendBytesToPrinter(printerName, datas)
Return ok
End Function ' SendFileToPrinter()
End Class
'--------------------------------------------------------------------------------
Vielen, vielen Dank Thomas für Deine Hilfe,
diese Info´s werden mir hoffentlich helfen :-))!!
Danke nochmal für DEINE! ganzen Bemühungen,
weiter so :-))))
Gruss
Stefan