c# - Printing UTF-8 Encoded Text in EPSON TM-T88IV Thermal Printer -
I have used the instructions given below to print via .net for EPSON TM-T88IV thermal printer. .
I am using the code below, I have changed the encoding to UTF-8 but still Unicode can not be printed.
Some junk characters are printed.
Private zero frmMain_Load (Object Sender, EventArgs e) {Print (PrinterName, GetDocument ()); } Private prong string PrinterName = "Epson TM-T88IV receipt E4"; Private Static Byte [] GetDocument () {UTF8Encoding utf8 = New UTF8Encoding (); (Var ms = new MemoryStream ()) (var bw = new BinaryWriter (MS, encoding. UTF8)) // Reset printer bws (NV images have not been cleaned) bw.Write (AsciiControlChars Escape); wife. White ("سلام دنیا"); Bw.Write (AsciiControlChars.Newline); // Feed 3 vertical speed units and cut a paper with a 1 point cut BWWright (AsciiControlChars.GroupSeparator); Bw.Write ('V'); Bw.Write (byte) 66); Bw.Write (byte) 3); Bw.flush (); Return to MS. ToArray (); }} Private static zero print (string printer-name, byte [] document) {Basic methods. DOC_INFO_1 documentInfo; IntPtr printerHandle; DocumentInfo = New Basic Methods DOC_INFO_1 (); DocumentInfo.pDataType = "Raw"; DocumentInfo.pDocName = "Bit Image Test"; PrinterHandle = new interface (0); If the (native methods .inter.exe), print printerHandle, IntPtr.Zero) (if the original methods. Start DockPrinter (PrinterHandle, 1, DocumentInfo)) {int written bytes; Byte [] ManageData; IntPtr unmanagedData; ManagedData = Document; UnmanagedData = Marshal.AllocCoTaskMem (managedData.Length); Marshall.Copy (managed data, 0, unmanaged data, managed data leng); If (Basic methods. StartPagePrinter (PrinterHandal)) {Native Methods.PrintPrinter (PrinterHandal, UnmanagedData, managedDataLabel, Written Bytes Out); NativeMethods.EndPagePrinter (printerHandle); } And {new Win32Exception (); } Marshal.Freakoscams (unmanaged data); NativeMethods.EndDocPrinter (printerHandle); } And {new Win32Exception (); } Basic methods Close printer (printer handles); } And {new Win32Exception (); }}
Comments
Post a Comment