I have a pocket PC with Windows mobile as OS. With it, I have a printer Zebra MZ320. My communication protocol is Bluetooth.
I connected the Bluetooth printer to the COM4 of the Windows mobile device.
I want now to print non ASCII code. The Windows mobile cannot support that, but at least it can print images.
So you have to convert your text and everything into image (the design depends on you) and print it.
First, take some files from
Zebra website, the SDK and the ZebraUtilities, it's free after free registration.
If your printer is not Zebra, you can probably find a similar product from the vendor website.
Install the
ZebraUtilities.cab on your Mobile device.
Use the DDLs from the SDK to your project by adding reference.
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO.Ports;
using System.Windows.Forms;
using ZSDK_API.ApiException;
using ZSDK_API.Comm;
using ZSDK_API.Printer;
namespace SmartFarsiTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void MenuExitClick(object sender, EventArgs e)
{
Application.Exit();
}
private void MenuPrintClick(object sender, EventArgs e)
{
CreateImage();
PrintOverSerial();
}
private void PrintOverSerial()
{
try
{
ZebraPrinterConnection thePrinterConn = new SerialPrinterConnection("COM4", 9600, 8, Parity.None, StopBits.One, Handshake.None);
thePrinterConn.Open();
var printer = ZebraPrinterFactory.GetInstance(thePrinterConn);
printer.GetGraphicsUtil().PrintImage(@"\My Documents\LastPrint.jpg",50,50);
thePrinterConn.Close();
}
catch (ZebraPrinterConnectionException e)
{
MessageBox.Show(e.StackTrace);
}
}
private static void CreateImage()
{
const float TicketWidth = 320;
var PrintableArea1 = new RectangleF(0, 7, TicketWidth, 20);
var PrintableArea2 = new RectangleF(0, PrintableArea1.Bottom, TicketWidth, 20);
var PrintableArea3 = new RectangleF(0, PrintableArea2.Bottom, TicketWidth, 20);
var PrintableArea4 = new RectangleF(0, PrintableArea3.Bottom, TicketWidth, 20);
var PrintableArea5 = new RectangleF(0, PrintableArea4.Bottom, TicketWidth, 20);
var PrintableArea6 = new RectangleF(0, PrintableArea5.Bottom, TicketWidth, 20);
var PrintableArea7 = new RectangleF(0, PrintableArea6.Bottom, TicketWidth, 20);
var PrintableArea8 = new RectangleF(0, PrintableArea7.Bottom, TicketWidth, 20);
var PrintableArea9 = new RectangleF(0, PrintableArea8.Bottom, TicketWidth, 20);
var PrintableArea10 = new RectangleF(0, PrintableArea9.Bottom,TicketWidth, 20);
var objBrushForeColor = new SolidBrush(Color.Black);
var objBrushBackColor = new SolidBrush(Color.White);
var objFont = new Font("Tahoma", 14, FontStyle.Regular);
var objBitmap = new Bitmap(320, 300);
var objGraphics = Graphics.FromImage(objBitmap);
objGraphics.FillRectangle(objBrushBackColor, 0, 0, 320, 300);
var sf = new StringFormat
{
Alignment = StringAlignment.Far,
FormatFlags = StringFormatFlags.NoWrap,
LineAlignment = StringAlignment.Far
};
objGraphics.DrawString("سفارش خرید کالا ", objFont, objBrushForeColor, PrintableArea1,sf);
objGraphics.DrawString("شرکت پیام سامان", objFont, objBrushForeColor, PrintableArea2,sf );
objGraphics.DrawString("تست", objFont, objBrushForeColor, PrintableArea3,sf);
objGraphics.DrawString("زرشک پولو", objFont, objBrushForeColor, PrintableArea4,sf);
objGraphics.DrawString("ماهی", objFont, objBrushForeColor, PrintableArea5,sf);
objGraphics.DrawString("بادمجون", objFont, objBrushForeColor, PrintableArea6, sf);
objGraphics.DrawString("کیبورد", objFont, objBrushForeColor, PrintableArea7, sf);
objGraphics.DrawString("ماوس", objFont, objBrushForeColor, PrintableArea8, sf);
objGraphics.DrawString("زیتون", objFont, objBrushForeColor, PrintableArea9, sf);
objGraphics.DrawString("هویج", objFont, objBrushForeColor, PrintableArea10, sf);
objGraphics.DrawLine(new Pen(Color.Black, 2), 0, (int)PrintableArea10.Bottom, 320, (int)PrintableArea10.Bottom);
objBitmap.Save(@"\My Documents\LastPrint.jpg", ImageFormat.Jpeg);
}
}
}
I'm from Madagascar and live in Iran.
I read Mathematics to the University of Madagascar.
And now I'm working to the company Payam-Saman in Iran.