P
Peter Morris
Hi all
I am trying to print a B&W PCX image to a Zebra RW420 file. The printer
uses the CPCL language, the help file says....
Input 1 (STARTPCX.LBL):
! 0 200 200 500 1
PCX 0 30
Input 2 (IMAGE.PCX)
Input 3 (ENDPCX.LBL)
FORM
PRINT
What I interpret as this
! 0 200 200 500 1
PCX 0 30 {binary data}
FORM
PRINT
or
! 0 200 200 500 1
PCX 0 30
{binary data}
FORM
PRINT
Neither of these are working. I have tried sending the binary data directly
as ASCII.GetBytes, and also tried reading each byte and converting it to an
ASCII HEX format 00-FF.
Does anyone have any experience with this? The guy on the support desk
seems to think this is enough, but it is just doing nothing at all! Any
help appreciated.
PS: I cannot use a file reference in the PCX, I must embed the file data
into the string because I am storing it away in a DB and printing it later
so I only have access to a string.
private void button1_Click(object sender, EventArgs e)
{
StringBuilder data = new StringBuilder();
data.Append("! 0 200 200 500 1\r\n");
data.Append("PCX 0 30 ");
data.Append(HexEncodedPCXData("/SDMMC DISK/x.pcx") + "\r\n");
data.Append("FORM\r\n");
data.Append("PRINT\r\n");
byte[] binary =
System.Text.ASCIIEncoding.ASCII.GetBytes(data.ToString());
//Output the file just so I can see what it is sending
FileStream fs = new FileStream("/SDMMC Disk/output.bin",
FileMode.Create);
fs.Write(binary, 0, binary.Length);
fs.Close();
ZebraPrintCtlClass zebraPrinter = new ZebraPrintCtlClass();
try
{
zebraPrinter.SerialConnection(string.Format("COM{0}:", 6), 19200);
zebraPrinter.Open();
zebraPrinter.Print(data.ToString());
}
finally
{
zebraPrinter.Close();
}
}
private string HexEncodedPCXData(string fileName)
{
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read,
FileShare.None);
byte[] buffer = new byte[fs.Length];
BinaryReader reader = new BinaryReader(fs);
using (reader)
reader.Read(buffer, 0, (int)fs.Length);
string result = System.Text.ASCIIEncoding.ASCII.GetString(buffer, 0,
buffer.Length);
return result;
}
I am trying to print a B&W PCX image to a Zebra RW420 file. The printer
uses the CPCL language, the help file says....
Input 1 (STARTPCX.LBL):
! 0 200 200 500 1
PCX 0 30
Input 2 (IMAGE.PCX)
Input 3 (ENDPCX.LBL)
FORM
What I interpret as this
! 0 200 200 500 1
PCX 0 30 {binary data}
FORM
or
! 0 200 200 500 1
PCX 0 30
{binary data}
FORM
Neither of these are working. I have tried sending the binary data directly
as ASCII.GetBytes, and also tried reading each byte and converting it to an
ASCII HEX format 00-FF.
Does anyone have any experience with this? The guy on the support desk
seems to think this is enough, but it is just doing nothing at all! Any
help appreciated.
PS: I cannot use a file reference in the PCX, I must embed the file data
into the string because I am storing it away in a DB and printing it later
so I only have access to a string.
private void button1_Click(object sender, EventArgs e)
{
StringBuilder data = new StringBuilder();
data.Append("! 0 200 200 500 1\r\n");
data.Append("PCX 0 30 ");
data.Append(HexEncodedPCXData("/SDMMC DISK/x.pcx") + "\r\n");
data.Append("FORM\r\n");
data.Append("PRINT\r\n");
byte[] binary =
System.Text.ASCIIEncoding.ASCII.GetBytes(data.ToString());
//Output the file just so I can see what it is sending
FileStream fs = new FileStream("/SDMMC Disk/output.bin",
FileMode.Create);
fs.Write(binary, 0, binary.Length);
fs.Close();
ZebraPrintCtlClass zebraPrinter = new ZebraPrintCtlClass();
try
{
zebraPrinter.SerialConnection(string.Format("COM{0}:", 6), 19200);
zebraPrinter.Open();
zebraPrinter.Print(data.ToString());
}
finally
{
zebraPrinter.Close();
}
}
private string HexEncodedPCXData(string fileName)
{
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read,
FileShare.None);
byte[] buffer = new byte[fs.Length];
BinaryReader reader = new BinaryReader(fs);
using (reader)
reader.Read(buffer, 0, (int)fs.Length);
string result = System.Text.ASCIIEncoding.ASCII.GetString(buffer, 0,
buffer.Length);
return result;
}