private void printfunction(string cmd)
{
string command = cmd;
// Create a buffer with the command
Byte[] buffer = new byte[command.Length];
buffer = System.Text.Encoding.ASCII.GetBytes(command);
// Use the CreateFile external functo connect to the LPT1 port
SafeFileHandle printer = CreateFile("LPT1:", FileAccess.ReadWrite, 0, IntPtr.Zero, FileMode.Open, 0, IntPtr.Zero);
// Aqui verifico se a impressora é válida
if (printer.IsInvalid == true)
{
MessageBox.Show("Printer not found!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
// Open the filestream to the lpt1 port and send the command
FileStream lpt1 = new FileStream(printer, FileAccess.ReadWrite);
lpt1.Write(buffer, 0, buffer.Length);
// Close the FileStream connection
lpt1.Close();
}
I've been using the code function above to send raw data to my ESC/POS supported EPSON TM88III printer.
I've only 3 sent of fonts by default in printer. But I wan't to print in ARIAL FONT. How can we print in Arial font.
Please don't suggest me to use windows print spooler or printer driver. I want to print by sending raw data.
How can we do this?
The coding is done in C#.NET using Visual Studio 2008.
As far as I know, the TM88's windows driver simply sends the print output as a bitmap to the printer, because the TM88 does not natively support anything more than fixed-width text, barcodes, and bitmaps.
You can use escape codes to switch between serif and sans-serif fonts, but they will both be fixed-width.