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();
}
上記のコード関数を使用して、ESC/POSでサポートされているEPSONTM88IIIプリンターに生データを送信しています。
プリンタでは、デフォルトで3つのフォントしか送信していません。しかし、私はARIALFONTで印刷したくありません。Arialフォントで印刷するにはどうすればよいですか。
Windowsプリントスプーラーまたはプリンタードライバーの使用を提案しないでください。生データを送って印刷したい。
どうすればこれを行うことができますか?
コーディングは、Visual Studio 2008を使用してC#.NETで行われます。